Method: Pkg::Util::Git.sha

Defined in:
lib/packaging/util/git.rb

.sha(length = 40) ⇒ Object

return the sha of HEAD on the current branch You can specify the length you want from the sha. Default is 40, the length for sha1. If you specify anything higher, it will still return 40 characters. Ideally, you’re not going to specify anything under 7 characters, but I’ll leave that discretion up to you.



83
84
85
86
87
88
# File 'lib/packaging/util/git.rb', line 83

def sha(length = 40)
  Pkg::Util.in_project_root do
    stdout, = Pkg::Util::Execution.capture3("#{Pkg::Util::Tool::GIT} rev-parse --short=#{length} HEAD")
    stdout.strip
  end
end