mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
25 lines
756 B
Ruby
25 lines
756 B
Ruby
# typed: strict
|
|
# frozen_string_literal: true
|
|
|
|
module Utils
|
|
extend T::Sig
|
|
|
|
sig do
|
|
params(repo: T.any(String, Pathname), length: T.nilable(Integer), safe: T::Boolean).returns(T.nilable(String))
|
|
end
|
|
def self.git_head(repo = Pathname.pwd, length: nil, safe: true)
|
|
return git_short_head(repo, length: length) if length.present?
|
|
|
|
repo = Pathname(repo).extend(GitRepositoryExtension)
|
|
repo.git_head(safe: safe)
|
|
end
|
|
|
|
sig do
|
|
params(repo: T.any(String, Pathname), length: T.nilable(Integer), safe: T::Boolean).returns(T.nilable(String))
|
|
end
|
|
def self.git_short_head(repo = Pathname.pwd, length: nil, safe: true)
|
|
repo = Pathname(repo).extend(GitRepositoryExtension)
|
|
repo.git_short_head(length: length, safe: safe)
|
|
end
|
|
end
|