mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-03 00:57:52 +02:00
Fix the CurrentBranchName function
The function would return "head/branchname" when there was either a tag or a remote with the same name. While fixing this we slightly change the semantic of the function (and of determineCheckedOutBranchName, which calls it): for a detached head it now returns an empty string rather than the commit hash. I actually think this is better.
This commit is contained in:
@ -102,12 +102,10 @@ func (self *BranchCommands) CurrentBranchInfo() (BranchInfo, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// CurrentBranchName get name of current branch
|
||||
// CurrentBranchName get name of current branch. Returns empty string if HEAD is detached.
|
||||
func (self *BranchCommands) CurrentBranchName() (string, error) {
|
||||
cmdArgs := NewGitCmd("rev-parse").
|
||||
Arg("--abbrev-ref").
|
||||
Arg("--verify").
|
||||
Arg("HEAD").
|
||||
cmdArgs := NewGitCmd("branch").
|
||||
Arg("--show-current").
|
||||
ToArgv()
|
||||
|
||||
output, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||
|
Reference in New Issue
Block a user