summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-02-19 00:13:46 +0100
committerGitHub <noreply@github.com>2023-02-19 10:13:46 +1100
commit979c3d62784487d0299636c545599d35c2b08bcf (patch)
tree2552868b2e9968c9a73be99daa1d84372b5b8338 /pkg/commands
parent1fc88238255380e8adde295aabeaaa870737c0d9 (diff)
Fix yellow/red coloring of pushed/unpushed commits in branch commits panel (#2448)
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/commit_loader.go4
-rw-r--r--pkg/commands/git_commands/commit_loader_test.go13
2 files changed, 16 insertions, 1 deletions
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
@@ -48,6 +48,19 @@ func TestGetCommits(t *testing.T) {
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",
rebaseMode: enums.REBASE_MODE_NONE,