From f765903e25e2b7720a3cf52b78700275eb0197d5 Mon Sep 17 00:00:00 2001 From: Ranjit Viswakumar Date: Fri, 20 Nov 2015 13:29:17 +0000 Subject: [PATCH 1/2] Checking for git first --- scripts/config_version.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/config_version.sh b/scripts/config_version.sh index 0aa9fb4..b4e6556 100755 --- a/scripts/config_version.sh +++ b/scripts/config_version.sh @@ -3,5 +3,7 @@ if [ -e /opt/puppetlabs/server/pe_version ] then /opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2 else - /usr/bin/git --git-dir $1/$2/.git rev-parse HEAD + /usr/bin/git --version > /dev/null 2>&1 && + /usr/bin/git --git-dir $1/$2/.git rev-parse HEAD || + date +%s fi From c2bd0d3ca1fd4e9f2fce24196201835272fd1e21 Mon Sep 17 00:00:00 2001 From: Ranjit Viswakumar Date: Fri, 20 Nov 2015 14:12:47 +0000 Subject: [PATCH 2/2] Check for rugged or output UNIX epoch --- scripts/config_version.rb | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/config_version.rb b/scripts/config_version.rb index b61e929..30b6b67 100755 --- a/scripts/config_version.rb +++ b/scripts/config_version.rb @@ -1,17 +1,23 @@ -require 'rugged' +begin + require 'rugged' +rescue LoadError => e + t = Time.new + puts t.to_i +else -environmentpath = ARGV[0] -environment = ARGV[1] + environmentpath = ARGV[0] + environment = ARGV[1] -repo = Rugged::Repository.discover(File.join(environmentpath, environment)) -head = repo.head + repo = Rugged::Repository.discover(File.join(environmentpath, environment)) + head = repo.head -#sha1 hash of the newest commit -head_sha = head.target_id + #sha1 hash of the newest commit + head_sha = head.target_id -#the commit message associated the newest commit -commit = repo.lookup(head_sha) + #the commit message associated the newest commit + commit = repo.lookup(head_sha) -#add something to find the remote url + #add something to find the remote url -puts head_sha + puts head_sha +end