Skip to content

Commit 3f172ad

Browse files
committed
Add contional and tests
1 parent e4b9f7c commit 3f172ad

File tree

4 files changed

+301
-154
lines changed

4 files changed

+301
-154
lines changed

git/git.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ func Commits(baseRef, headRef string) ([]*Commit, error) {
181181
}
182182

183183
func LastCommit() (*Commit, error) {
184-
logCmd := GitCommand("-c", "log.ShowSignature=false", "log", "--pretty=format:%H,%s", "-1")
184+
logCmd, err := GitCommand("-c", "log.ShowSignature=false", "log", "--pretty=format:%H,%s", "-1")
185+
if err != nil {
186+
return nil, err
187+
}
188+
185189
output, err := run.PrepareCmd(logCmd).Output()
186190
if err != nil {
187191
return nil, err

pkg/cmd/pr/merge/merge.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,12 @@ func mergeRun(opts *MergeOptions) error {
131131
return err
132132
}
133133

134-
localBranchName, err := git.CurrentBranch()
135-
if err == nil {
134+
if opts.SelectorArg == "" {
136135
localBranchLastCommit, err := git.LastCommit()
137136
if err == nil {
138-
if localBranchName == pr.HeadRefName && localBranchLastCommit.Sha != pr.Commits.Nodes[0].Commit.Oid {
137+
if localBranchLastCommit.Sha != pr.Commits.Nodes[0].Commit.Oid {
139138
fmt.Fprintf(opts.IO.ErrOut,
140-
"%s Pull request #%d (%s) may have a last commit that is different from local one\n", utils.Yellow("!"), pr.Number, pr.Title)
139+
"%s Pull request #%d (%s) has diverged from local branch\n", cs.Yellow("!"), pr.Number, pr.Title)
141140
}
142141
}
143142
}

0 commit comments

Comments
 (0)