Skip to content

Commit

Permalink
Merge pull request #21385 from sprohaska/pr/fix-automate-import-git
Browse files Browse the repository at this point in the history
Fix Automate Git import if branch is symbolic ref
  • Loading branch information
NickLaMuro authored Aug 23, 2021
2 parents d5f9552 + d005928 commit ab8d411
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/git_worktree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def branch=(name)
def branch_info(name)
branch = find_branch(name)
raise GitWorktreeException::BranchMissing, name unless branch
{:time => branch.target.time, :message => branch.target.message, :commit_sha => branch.target.oid}
ref = branch.resolve
{:time => ref.target.time, :message => ref.target.message, :commit_sha => ref.target.oid}
end

def tags
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ref: refs/heads/branch2
7 changes: 5 additions & 2 deletions spec/lib/git_worktree_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ def open_existing_repo

describe "#branches" do
it "all branches" do
expect(test_repo.branches).to match_array(%w(master branch1 branch2))
expect(test_repo.branches).to match_array(%w(master branch1 branch2 symbolic))
end

it "local branches only" do
expect(test_repo.branches(:local)).to match_array(%w(master branch1 branch2))
expect(test_repo.branches(:local)).to match_array(%w(master branch1 branch2 symbolic))
end

it "remote branches only" do
Expand All @@ -290,6 +290,9 @@ def open_existing_repo
it "get branch info" do
expect(test_repo.branch_info('branch2').keys).to match_array([:time, :message, :commit_sha])
end
it "get branch info symbolic ref" do
expect(test_repo.branch_info('symbolic').keys).to match_array([:time, :message, :commit_sha])
end
end

describe "#branch" do
Expand Down

0 comments on commit ab8d411

Please sign in to comment.