diff --git a/lib/git_worktree.rb b/lib/git_worktree.rb index adaa5667cfe..8bdb1a8a853 100644 --- a/lib/git_worktree.rb +++ b/lib/git_worktree.rb @@ -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 diff --git a/spec/fixtures/git_repos/branch_and_tag.git/refs/heads/symbolic b/spec/fixtures/git_repos/branch_and_tag.git/refs/heads/symbolic new file mode 100644 index 00000000000..1d57c9ea7fc --- /dev/null +++ b/spec/fixtures/git_repos/branch_and_tag.git/refs/heads/symbolic @@ -0,0 +1 @@ +ref: refs/heads/branch2 diff --git a/spec/lib/git_worktree_spec.rb b/spec/lib/git_worktree_spec.rb index 183fbaba7e4..697b0d7f588 100644 --- a/spec/lib/git_worktree_spec.rb +++ b/spec/lib/git_worktree_spec.rb @@ -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 @@ -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