Skip to content

Add an option -since-latest-release #2

Merged
buchanae merged 11 commits intobuchanae:masterfrom
duck8823:feature/new_pr_option
Jul 28, 2018
Merged

Add an option -since-latest-release #2
buchanae merged 11 commits intobuchanae:masterfrom
duck8823:feature/new_pr_option

Conversation

@duck8823
Copy link
Copy Markdown
Contributor

Hi, thank you for great tool !

But I wont a option that notes only new PRs.

Here, I just add a -since-latest-release.
This option analyze with latest release tag, compared commit sha and pr's commits from GitHub, and stop notes already released PR automatically.

@duck8823 duck8823 changed the title Add an option for Add an option -since-latest-release Jul 23, 2018
Copy link
Copy Markdown
Owner

@buchanae buchanae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks for doing this. I've been wanting this feature.

I have a few minor comments, but I have tried this and it seems to work.

ghrn/ghrn.go Outdated
StopAt int
// IncludeCommits will include commmits messages for each PR.
IncludeCommits bool
// StopAtLatestRelease will stop at latest release commit.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call this "SinceLatestRelease" to match the flag. Docs would be "SinceLatestRelease will only include PRs and commits merged since the latest release tag."

ghrn/ghrn.go Outdated
comp, _, err := cl.Repositories.CompareCommits(ctx, conf.Org, conf.Repo, rls.GetTagName(), repo.GetDefaultBranch())
if err != nil {
return fmt.Errorf("compare commitse: %s..%s %+v", rls.GetTagName(), repo.GetDefaultBranch(), err)
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are only needed for when conf.SinceLatestRelease is true. Can you move these to a helper, and only use them if we're conf.SinceLatestRelease == true? This would avoid a few calls to github and maybe save 1-2 seconds in some cases.

ghrn/ghrn.go Outdated
var newCommits []string
for _, commit := range comp.Commits {
newCommits = append(newCommits, commit.GetCommit().GetTree().GetSHA())
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this in a helper?

Perhaps something like:

function commitHashes(commits []*github.RepositoryCommit) []string {}

newCommits := commitHashes(comp.Commits)

ghrn/ghrn.go Outdated
}

if conf.StopAtLatestRelease && !any(prCommits, newCommits) {
// stop any new commits do not contains pr commits
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little help with the English: "Stop when a PR doesn't contain any commits from since the latest release."

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, technically it's possible to have a PR that was merged to a branch besides master after the latest release, in which case this code would stop early and produce incorrect release notes.

readme.md Outdated
- PR #514 build: fix release notes command
```

You can generating notes with PR that not included latest release:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"You can generate notes for only PRs merged since the latest release:"

@buchanae buchanae merged commit efd2add into buchanae:master Jul 28, 2018
@duck8823
Copy link
Copy Markdown
Contributor Author

Thank you for the merge and your carefully review!! And sorry for my poor English...

I just added commit duck8823@beebe15 to respond to the review comment #2 (comment) after your merge...

@buchanae
Copy link
Copy Markdown
Owner

@duck8823 can you open a new PR with the commit I missed please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants