Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define pull request conventions #9

Open
mojavelinux opened this issue Mar 30, 2021 · 11 comments
Open

Define pull request conventions #9

mojavelinux opened this issue Mar 30, 2021 · 11 comments

Comments

@mojavelinux
Copy link
Member

Within the Asciidoctor community of projects, I think we should agree on a general set of conventions / guidelines for PRs (at the very least, for the core projects and those closely associated with it). This will make it easier to work in the various projects without having to remember what all the individual rules are. I have been adhering certain conventions over the years, but even those may need to be revisited and revised. What I'm about to propose are meant to be general guidelines, not strict rules. But the closer we stick to the guidelines, the easier it is to get into the flow.

  • issue requirement - First, I think it should be a recommendation that every human-created PR has an associated issue. The idea is that the issue is where the decision is made to approve the proposed idea and proceed with a code fix before anyone has invested time working on it. It's also where the architecture for the issue can be discussed. The issue number is what gets referenced by the CHANGELOG, so we want that to point to that initial conversation / full context. The PR can then be focused on the code review itself.

  • branch name - Second, The branch from which the PR is submitted should include the issue number and a short description in the form issue-<issue number>-<desc> (e.g., issue-1897-keep-anchor-with-block). This makes it easier to organize branches locally and ensures we don't get PRs from branches that are changing while we are trying to review the PR.

  • subject line - Third, we should agree on the format for the subject line for a PR. Should it start with an action keyword, like fixes|resolves|closes <issue number>? If we use these prefixes, when it's merged, the issue automatically gets closed. I know that GitHub refuses to recognize the issue number in the subject. But if it's not in the subject, then you can't quickly scan for issue-closing commits in the git history after merging it. So perhaps we need it in both the subject and the description.

  • changelog entry - Fourth, every PR should include an addition to the CHANGELOG. I know some people like to generate a CHANGELOG at the time of a release, but then no one knows what's in a release until it's made. Keeping the CHANGELOG up to date with each merge has proved to be very effective in communicating what's coming. It's a living document. It also makes doing the release a lot simpler.

  • merge strategy - Finally, how do we merge and what template do we use for the subject? Thus far, I've been using resolves #<issue number> summary goes here (PR #<pr number>). Does that seem right? Here's how it looks: asciidoctor/asciidoctor@a1505ef

Of course, we can't mandate behavior. That's not the point. The point is for us maintainers to lead by example and develop a workflow that's consistent and works well across the projects. What other recommendations would you add that have proven to work well?

@slonopotamus
Copy link
Contributor

slonopotamus commented Mar 31, 2021

Thus far, I've been using resolves #<issue number> summary goes here (PR #<pr number>).

Please, please, omit that PR . I am just too lazy and forget every time to type PR . GitHub itself autosuggests just (#number), without PR part.

This makes it easier to organize branches locally

I don't think conventions should care how user organises their local branches? Also, most likely external contributors won't follow branch naming conventions. Will you reject their PRs just because they named the branch unconventionally? Note that it isn't possible to change branch name without recreating PR.

All the rest: I'm +1 about resolves <issue number> subject line, changelog entries, issue requirement and merge strategy that you use (rebase'n'squash).

@mojavelinux
Copy link
Member Author

Thanks for that feedback, Marat!

Will you reject their PRs just because they named the branch unconventionally?

As I stated, these are "meant to be general guidelines, not strict rules" and "we can't mandate behavior". This is about leading by example. So no, I would not consider the name of the branch to be grounds for rejecting a PR as long as it's a dedicated branch. However, if it's the main branch, that's when I would consider enforcing the rule and having the contributor resubmit.

Please, please, omit that PR #

I'm definitely willing to reconsider my practice here. However, I must profess that it's convenient to be able to jump directly from the history to the pull request, which GitHub otherwise doesn't provide.

I suppose we could restate this to say that we should ensure the issue is linked to the PR in the GitHub interface. That way, it's just one more click away.

@slonopotamus
Copy link
Contributor

However, I must profess that it's convenient to be able to jump directly from the history to the pull request, which GitHub otherwise doesn't provide.

I mean, GitHub provides a way to jump to PR, see asciidoctor/asciidoctor-epub3@38dd012 for example. So, commit message has both link to issue and link to PR. It just doesn't have PR text that you insert by hand)

@slonopotamus
Copy link
Contributor

And yep, I am literally talking about these three symbols: P, R and whitespace.

@mojavelinux
Copy link
Member Author

commit message has both link to issue and link to PR. It just doesn't have PR text that you insert by hand

Aha! I see what you're saying. That would be fine by me.

@slonopotamus
Copy link
Contributor

slonopotamus commented Mar 31, 2021

👍

So, WRT branch naming - I'm negative-neutral about adding such rule. When you see someone else's branch, you see it as a PR. So it is too late to rename it. When you create your own branch - name it whatever you like. We use rebase'n'squash strategy, so merged branch name doesn't appear in git history of target repository. So, what does branch name affect? The text that you see in PRs (gambhiro wants to merge 6 commits into asciidoctor:master from gambhiro:stylus)? It's that user namespace, they have full rights to name their own branches whatever they like. And I don't see other places where branch names would matter.

@mojavelinux
Copy link
Member Author

It helps considerably when I add the person's remote to my own repository and I'm navigating between branches. Without the issue number in the branch name, it quickly becomes confusing which branch is which. And the issue number alone gives no context outside of the issue tracker. So having both is idea.

I'm speaking here from several years of experience now using this practice. And it has proven itself to be very effective in my own workflow. Because it has made such a difference, I am now advocating for it as a best practice / guideline.

@abelsromero
Copy link
Member

abelsromero commented Mar 31, 2021 via email

@mojavelinux
Copy link
Member Author

Does 'merge strategy' include the merge type? aka-. Merge commit, squash
& merge, rebase

Yes, that's what I'm referring to. And I don't think I would suggest which one a project should use. But whatever one the project does use, I think how it's annotated should be consistent across projects.

I tend to use the squash and merge unless the PR has multiple discrete stages, in which case I might use the merge commit. But to be honest, I'm never quite sure what the right decision is.

@abelsromero
Copy link
Member

abelsromero commented Mar 31, 2021 via email

@ggrossetie
Copy link
Member

subject line - Third, we should agree on the format for the subject line for a PR. Should it start with an action keyword, like fixes|resolves|closes ? If we use these prefixes, when it's merged, the issue automatically gets closed. I know that GitHub refuses to recognize the issue number in the subject. But if it's not in the subject, then you can't quickly scan for issue-closing commits in the git history after merging it. So perhaps we need it in both the subject and the description.

For reference, I'm occasionally using ref #<issue number> title in the subject line when a pull request is related to an issue but does not fully resolve it.
Usually, it happens when I'm working on a new feature that requires multiple iterations. Sometimes it's easier (for everyone really!) to create small pull requests that are easier to review and merge them progressively rather than reviewing a large pull request again and again.

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

No branches or pull requests

4 participants