Skip to content

Commit

Permalink
Tolerate custom format.pretty settings in user .gitconfig
Browse files Browse the repository at this point in the history
parseLocalCommitStack assumes the commit log string conforms
to --pretty=/--format=medium. If the user has a custom
setting for format.pretty in .gitconfig (for example: oneline)
, this assumption can break and spr reports:
"pull request stack is empty".

This commit changes the git log command to always specify
--format=medium to avoid this issue.
  • Loading branch information
MichaelSims authored and ejoffe committed Apr 10, 2023
1 parent 96da77e commit 867ff5d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion git/mockgit/mockgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (m *Mock) ExpectFetch() {

func (m *Mock) ExpectLogAndRespond(commits []*git.Commit) {
m.expect("git branch --no-color").respond("* master")
m.expect("git log --no-color origin/master..HEAD").commitRespond(commits)
m.expect("git log --format=medium --no-color origin/master..HEAD").commitRespond(commits)
}

func (m *Mock) ExpectPushCommits(commits []*git.Commit) {
Expand Down
2 changes: 1 addition & 1 deletion spr/spr.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func (sd *stackediff) ProfilingSummary() {
func (sd *stackediff) getLocalCommitStack() []git.Commit {
var commitLog string
targetBranch := githubclient.GetRemoteBranchName(sd.gitcmd, sd.config.Repo)
logCommand := fmt.Sprintf("log --no-color %s/%s..HEAD",
logCommand := fmt.Sprintf("log --format=medium --no-color %s/%s..HEAD",
sd.config.Repo.GitHubRemote, targetBranch)
sd.mustgit(logCommand, &commitLog)
commits, valid := sd.parseLocalCommitStack(commitLog)
Expand Down

0 comments on commit 867ff5d

Please sign in to comment.