From 979c3d62784487d0299636c545599d35c2b08bcf Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 19 Feb 2023 00:13:46 +0100 Subject: [PATCH] Fix yellow/red coloring of pushed/unpushed commits in branch commits panel (#2448) --- pkg/commands/git_commands/commit_loader.go | 4 +++- pkg/commands/git_commands/commit_loader_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 00e2f80ad..03fe4e1b2 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -401,7 +401,9 @@ func ignoringWarnings(commandOutput string) string { func (self *CommitLoader) getFirstPushedCommit(refName string) (string, error) { output, err := self.cmd. New( - fmt.Sprintf("git merge-base %s %s@{u}", self.cmd.Quote(refName), self.cmd.Quote(refName)), + fmt.Sprintf("git merge-base %s %s@{u}", + self.cmd.Quote(refName), + self.cmd.Quote(strings.TrimPrefix(refName, "refs/heads/"))), ). DontLog(). RunWithOutput() diff --git a/pkg/commands/git_commands/commit_loader_test.go b/pkg/commands/git_commands/commit_loader_test.go index aa20ae802..1754ede6a 100644 --- a/pkg/commands/git_commands/commit_loader_test.go +++ b/pkg/commands/git_commands/commit_loader_test.go @@ -47,6 +47,19 @@ func TestGetCommits(t *testing.T) { expectedCommits: []*models.Commit{}, expectedError: nil, }, + { + testName: "should use proper upstream name for branch", + logOrder: "topo-order", + rebaseMode: enums.REBASE_MODE_NONE, + currentBranchName: "mybranch", + opts: GetCommitsOptions{RefName: "refs/heads/mybranch", IncludeRebaseCommits: false}, + runner: oscommands.NewFakeRunner(t). + Expect(`git merge-base "refs/heads/mybranch" "mybranch"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil). + Expect(`git -c log.showSignature=false log "refs/heads/mybranch" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, "", nil), + + expectedCommits: []*models.Commit{}, + expectedError: nil, + }, { testName: "should return commits if they are present", logOrder: "topo-order",