diff options
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/git_commands/commit_loader.go | 4 | ||||
-rw-r--r-- | pkg/commands/git_commands/commit_loader_test.go | 13 |
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, |