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

[all] Pull Request methodology #779

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Roman-Manevich
Copy link
Collaborator

I'm hoping that we can agree on a methodology for using git/github to publish new features. Here is my attempt.

Copy link
Member

@relokin relokin left a comment

Choose a reason for hiding this comment

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

Thanks @Roman-Manevich!

This is a very good starting point. This is very similar to the flow I would use but before we recommend that everyone adopts a flow that allows a linear history we need a wider consensus.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@maranget
Copy link
Member

maranget commented Feb 6, 2024

Hi all, thanks for this initiative. I'd like to be clear about what history we have in the end:

A linear history, with PR being merged one after the other, with explicit merge messages, without any overlap. This can be checked as git lg with the following lines in one's .gitconf file

[alias]
        lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

We also want the tests (make test) to succeed after every commit (again to facilitate bisecting). A relatively light technique to achieve this is to squash the PR commits into one or a few ones (another technique is to run make all test after each commit, which is arguably heavier).

Hence, once the PR is ready, that is, once merge has been agreed, the PR authors can proceed as follows, from their branch (if I am not wrong):

  1. Rebase on top of master with git rebase master.
  2. Squash commits into one or a few with git rebase -i.
  3. Force push with git push --force.

It is to be noticed that the merger can do the same, but this means pushing to the author's clone and slightly alters authorship.

Finally, the merger has to fill the merge message, it is often convenient to copy the initial message of the conversation, which usually describes the effect and purpose of the PR.

@relokin
Copy link
Member

relokin commented Feb 6, 2024

Thanks for this @maranget. I agree with everything just some questions/comments.

We also want the tests (make test) to succeed after every commit (again to facilitate bisecting). A relatively light technique to achieve this is to squash the PR commits into one or a few ones (another technique is to run make all test after each commit, which is arguably heavier).

I think there is still value in keeping multiple commits in a PR if:

  • Each of the commit in the PR passes make test as you pointed out, and
  • Each commit implements a logical change.
    Some PRs implement large features and being able to split into different logical changes, I think helps. In fact, it's way easier for the reviewer or anyone trying to understand a PR, if the reviewing load can be split in reasonably sized meaningful changes. And there is no downside, if one wants to see only merge commits, they can do so with git lg --merges. So squashing is not only reducing information.

On the other hand, sometime this is not information worth keeping. If the commit history in the PR is not clean, with fixes on top of each, I would argue that these sequence of changes is not worth keeping in the project's history, they only add noise and squashing is the right strategy.

It is to be noticed that the merger can do the same, but this means pushing to the author's clone and slightly alters authorship.

I agree it's not ideal, but when I squash commits together, I retain the Author information. git automatically changes the Commit field.

Finally, the merger has to fill the merge message, it is often convenient to copy the initial message of the conversation, which usually describes the effect and purpose of the PR.

That's a very good point. I will start doing it.

Edited README.md to add an greed upon methodology for creating and
publishing a pull request with git and github.
@Roman-Manevich Roman-Manevich force-pushed the version-control-contributing branch from b46b20e to 45a780d Compare February 12, 2024 16:45
@Roman-Manevich Roman-Manevich force-pushed the version-control-contributing branch from 45a780d to 7d365dd Compare February 13, 2024 13:02
@Roman-Manevich Roman-Manevich changed the title Pull Request methodology [all] Pull Request methodology Feb 19, 2024
Copy link
Collaborator

@artkhyzha artkhyzha left a comment

Choose a reason for hiding this comment

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

LGTM -- this is more or less what I do too.

I added two nitpick-y comments, to check if I understood the flow correctly than anything else.

responsibly.
Therefore, our recommendation to all contributors is to follow the following
procedure:
1. Create a [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Step 6 as I understand it assumes that the remote pf the fork is called "origin" and does not rely on there being a name for the fork. Step 7 as I understand it assumes that "upstream" is indeed 'herd/herdtools7" on Github.

So, maybe this could be something like "Create a fork and clone it. Add a remote for the original repository, call it upstream"?

`make test`.
6. Assuming `origin` is your clone of `herdtools7`, push with
`git push --set-upstream origin feature`
7. Rebase often, repeating 2--6 as much as needed:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Strictly speaking not necessary for the sequence of steps here, but I wonder if it is useful to keep origin's master branch up to date with upstream's master branch. Presumably, step 2 is good to do branching off up-to-date master.

I usually press a button on the web interface for this ("Sync fork" on the forked page).

Therefore, our recommendation to all contributors is to follow the following
procedure:
1. Create a [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)
of `herdtools7` named, for example, `upstream` and set `herdtools7` as your remote.
Copy link
Member

@relokin relokin Mar 14, 2024

Choose a reason for hiding this comment

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

To make this more clear I think you can break it down into further steps
2. Clone your fork of herdtools7: git clone [email protected]:${GITHUB_USERNAME}/herdtools7
1 and 2 are steps need only the first time.

The one option would be to add herd/herdtools7 as a remote:
4. From the folder in which the repository is cloned add herd/herdtools7 as a remote: git remote add upstream https://github.com/herd/herdtools7.git
5. Fetch the latest refs form herd/herdtools7 git fetch upstream

Otherwise and as Artem suggested:
4. Sync your fork with the upstream repository using github's "Sync fork" (not sure of the details of this, I've never used it)
5. Fetch the latest refs of your remote repository with git fetch

procedure:
1. Create a [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)
of `herdtools7` named, for example, `upstream` and set `herdtools7` as your remote.
2. Create a git branch: `git checkout -b feature`
Copy link
Member

@relokin relokin Mar 14, 2024

Choose a reason for hiding this comment

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

Suggested change
2. Create a git branch: `git checkout -b feature`
2. Create a git branch: `git checkout upstream/master -b <feature_name>`

or if you follow Artem's approach
git checkout origin/master -b <feature_name>

Also, `[all]` applies to changes that effect several components.
5. Test the feature and make sure all relevant tests pass, including
`make test`.
6. Assuming `origin` is your clone of `herdtools7`, push with
Copy link
Member

Choose a reason for hiding this comment

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

As Artem said this is the default behaviour, if you want you can add a comment to this extend when you instruct users to add the upstream remote, but here this is unnecessary.

Copy link
Collaborator

@HadrienRenaud HadrienRenaud left a comment

Choose a reason for hiding this comment

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

Hi @Roman-Manevich, thank you for writing this.

I agree with the comments that most of those steps need more explanation.
I would like to add that external references can (and probably should) be used to provide more detailed and up-to-date explanations. For example, the steps on rebasing are confusing, and we could point to an external tutorial, for example git-scm.

A fear I have is that such a text would deter occasional contributors. For example, while rebasing is good for people that do 5 PR a week (me? 🙄), it might not be the easiest if you don't have a good knowledge of the code base and you only occasionally work on it, in which case a merge commit is probably fine.

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.

5 participants