Skip to content

Commit 3845774

Browse files
committed
improvements
1 parent 2784879 commit 3845774

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/gitrepo/merge.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ func MergeBase(ctx context.Context, repo Repository, commit1, commit2 string) (s
3333
// ref: https://git-scm.com/docs/git-merge-tree/2.38.0#OUTPUT
3434
func parseMergeTreeOutput(output string) (string, []string, error) {
3535
fields := strings.Split(strings.TrimSuffix(output, "\x00"), "\x00")
36-
if len(fields) == 0 {
36+
switch len(fields) {
37+
case 0:
3738
return "", nil, errors.New("unexpected empty output")
38-
}
39-
if len(fields) == 1 {
39+
case 1:
4040
return strings.TrimSpace(fields[0]), nil, nil
41+
default:
42+
return strings.TrimSpace(fields[0]), fields[1:], nil
4143
}
42-
return strings.TrimSpace(fields[0]), fields[1:], nil
4344
}
4445

4546
// MergeTree performs a merge between two commits (baseRef and headRef) with an optional merge base.

0 commit comments

Comments
 (0)