Skip to content

Commit

Permalink
fill oldest revision when from target is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Dec 31, 2017
1 parent 92e991f commit ed9a053
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 8 additions & 1 deletion cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (cli *CLI) Run(argv []string) int {
prevRev := ""
for _, rev := range vers {
r, err := gh.getSection(rev, prevRev)
if (err != nil) {
if err != nil {
log.Print(err)
return exitCodeErr
}
Expand Down Expand Up @@ -187,6 +187,13 @@ func parseArgs(args []string) (*flags.Parser, *ghOpts, error) {
}

func (gh *ghch) getSection(from, to string) (Section, error) {
if from == "" {
from, _ = gh.cmd("rev-list", "--max-parents=0", "HEAD")
from = strings.TrimSpace(from)
if len(from) > 12 {
from = from[:12]
}
}
r, err := gh.mergedPRs(from, to)
if err != nil {
return Section{}, err
Expand Down
7 changes: 1 addition & 6 deletions ghch.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (gh *ghch) ownerAndRepo() (owner, repo string) {
func (gh *ghch) mergedPRs(from, to string) (prs []*octokit.PullRequest, err error) {
owner, repo := gh.ownerAndRepo()
prlogs, err := gh.mergedPRLogs(from, to)
if (err != nil) {
if err != nil {
return
}
prs = make([]*octokit.PullRequest, 0, len(prlogs))
Expand Down Expand Up @@ -188,11 +188,6 @@ type mergedPRLog struct {
}

func (gh *ghch) mergedPRLogs(from, to string) (nums []*mergedPRLog, err error) {
if from == "" {
from, _ = gh.cmd("rev-list", "--max-parents=0", "HEAD")
from = strings.TrimSpace(from)
}

revisionRange := fmt.Sprintf("%s..%s", from, to)
out, err := gh.cmd("log", revisionRange, "--merges", "--oneline")
if err != nil {
Expand Down

0 comments on commit ed9a053

Please sign in to comment.