lib/plain_apm/hooks/deploy.rb in plain_apm-0.5.4 vs lib/plain_apm/hooks/deploy.rb in plain_apm-0.5.5
- old
+ new
@@ -32,20 +32,28 @@
# TODO: other deploy mechanisms
#
# Also, we might not be in the app root.
def git_revision
- return nil unless File.exist?(".git")
+ return unless File.exist?(".git")
- ["git", `git rev-parse --short HEAD`.strip]
+ rev = `git rev-parse --short=8 HEAD`.strip
+
+ return if rev.empty?
+
+ ["git", rev]
rescue Error::ENOENT # No git installed
nil
end
def hg_revision
- return nil unless File.exist?(".hg")
+ return unless File.exist?(".hg")
- ["hg", `hg log -l 1 -r . -T '{node}'`]
+ rev = `hg log -l 1 -r . -T '{node}'`.strip
+
+ return if rev.empty?
+
+ ["hg", rev]
rescue Error::ENOENT # No mercurial installed
nil
end
end
end