Skip to content

Commit

Permalink
Fixing NEW PR Auto fill (#6)
Browse files Browse the repository at this point in the history
* Fixing NEW PR Auto fill

Signed-off-by: Vittorio Ballestra <[email protected]>

* Adding error when no commmits

Signed-off-by: Vittorio Ballestra <[email protected]>
  • Loading branch information
dam0vm3nt authored Jan 7, 2023
1 parent 4182529 commit 204760c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/evertras/bubble-table v0.14.6
github.com/go-git/go-git/v5 v5.4.2
github.com/google/go-github/v43 v43.0.0
github.com/itchyny/timefmt-go v0.1.3
github.com/pterm/pterm v0.12.40
github.com/shurcooL/githubv4 v0.0.0-20200928013246-d292edc3691b
github.com/spf13/cobra v1.4.0
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/itchyny/gojq v0.12.7/go.mod h1:ZdvNHVlzPgUf8pgjnuDTmGfHA/21KoutQUJ3An/xNuw=
github.com/itchyny/timefmt-go v0.1.3 h1:7M3LGVDsqcd0VZH2U+x393obrzZisp7C0uEe921iRkU=
github.com/itchyny/timefmt-go v0.1.3/go.mod h1:0osSSCQSASBJMsIZnhAaF1C2fCBTJZXrnj37mG8/c+A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
Expand Down
10 changes: 7 additions & 3 deletions sv/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ func (g *GitHubSv) resolveTitleAndDescription(titleOpt optional.String, descript
}
mb := mbs[0]
isValid := object.CommitFilter(func(commit *object.Commit) bool {
if isAncestor, err := mb.IsAncestor(commit); err != nil {
if commit.ID() == mb.ID() {
return false
} else if isAncestor, err := mb.IsAncestor(commit); err == nil {
return isAncestor
} else {
return false
Expand All @@ -213,9 +215,11 @@ func (g *GitHubSv) resolveTitleAndDescription(titleOpt optional.String, descript

lastIdx := len(logs) - 1
if lastIdx > 0 {
return titleOpt.Default(logs[lastIdx]), descriptionOpt.Default(strings.Join(logs[0:lastIdx-1], "\n")), nil
} else {
return titleOpt.Default(logs[lastIdx]), descriptionOpt.Default(strings.Join(logs[0:lastIdx], "\n")), nil
} else if lastIdx == 0 {
return titleOpt.Default(logs[lastIdx]), "", nil
} else {
return "", "", fmt.Errorf("no commits from %v to %v, cannot infer pr title", baseBranch, headBranch)
}

}
Expand Down

0 comments on commit 204760c

Please sign in to comment.