Skip to content

Commit a9d3be5

Browse files
author
Gary Larizza
committed
Merge pull request #3 from WhatsARanjit/production
Chicken-and-egg issue
2 parents 10732cf + 2859cff commit a9d3be5

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

scripts/config_version.rb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
require 'rugged'
1+
begin
2+
require 'rugged'
3+
rescue LoadError => e
4+
t = Time.new
5+
puts t.to_i
6+
else
27

3-
environmentpath = ARGV[0]
4-
environment = ARGV[1]
8+
environmentpath = ARGV[0]
9+
environment = ARGV[1]
510

6-
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
7-
head = repo.head
11+
repo = Rugged::Repository.discover(File.join(environmentpath, environment))
12+
head = repo.head
813

9-
#sha1 hash of the newest commit
10-
head_sha = head.target_id
14+
#sha1 hash of the newest commit
15+
head_sha = head.target_id
1116

12-
#the commit message associated the newest commit
13-
commit = repo.lookup(head_sha)
17+
#the commit message associated the newest commit
18+
commit = repo.lookup(head_sha)
1419

15-
#add something to find the remote url
20+
#add something to find the remote url
1621

17-
puts head_sha
22+
puts head_sha
23+
end

scripts/config_version.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ if [ -e /opt/puppetlabs/server/pe_version ]
33
then
44
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
55
else
6-
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD
7-
fi
6+
/usr/bin/git --version > /dev/null 2>&1 &&
7+
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD ||
8+
date +%s
9+
fi

0 commit comments

Comments
 (0)