utils/git_repository: use Pathname.pwd
if no repo
specified
This commit is contained in:
parent
9f4105f325
commit
4f02c1c8a8
@ -20,6 +20,10 @@ describe Utils do
|
||||
it "returns the revision at HEAD" do
|
||||
expect(described_class.git_head(HOMEBREW_CACHE)).to eq(head_revision)
|
||||
expect(described_class.git_head(HOMEBREW_CACHE, length: 5)).to eq(head_revision[0...5])
|
||||
HOMEBREW_CACHE.cd do
|
||||
expect(described_class.git_head).to eq(head_revision)
|
||||
expect(described_class.git_head(length: 5)).to eq(head_revision[0...5])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -27,6 +31,10 @@ describe Utils do
|
||||
it "returns the short revision at HEAD" do
|
||||
expect(described_class.git_short_head(HOMEBREW_CACHE)).to eq(short_head_revision)
|
||||
expect(described_class.git_short_head(HOMEBREW_CACHE, length: 5)).to eq(head_revision[0...5])
|
||||
HOMEBREW_CACHE.cd do
|
||||
expect(described_class.git_short_head).to eq(short_head_revision)
|
||||
expect(described_class.git_short_head(length: 5)).to eq(head_revision[0...5])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Utils
|
||||
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, length: nil, safe: true)
|
||||
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)
|
||||
@ -17,7 +17,7 @@ module Utils
|
||||
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, length: nil, safe: true)
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user