-
Notifications
You must be signed in to change notification settings - Fork 96
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
Explain how to work with patches #3580
base: master
Are you sure you want to change the base?
Conversation
The PR preview for 7b57ff9 is available at theforeman-foreman-documentation-preview-pr-3580.surge.sh The following output files are affected by this PR: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this belong on https://community.theforeman.org/c/tutorials/23?
|
||
1. Fetch the PR from GitHub: | ||
|
||
$ git fetch upstream pull/1234/head:pr_1234_optional_description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With https://cli.github.com/ you can do gh pr checkout 1234
to check out a PR
|
||
3. View the patch: | ||
|
||
$ git show |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also git format-patch
:
$ gh pr checkout 3580
From https://github.com/theforeman/foreman-documentation
* [new ref] refs/pull/3580/head -> how-to-apply-patch
Switched to branch 'how-to-apply-patch'
$ vi CONTRIBUTING.md
$ git commit -am 'Use gh pr checkout'
[how-to-apply-patch 2a8be45942a4] Use gh pr checkout
1 file changed, 2 insertions(+), 2 deletions(-)
$ git status
On branch how-to-apply-patch
Your branch is ahead of 'upstream/pr/3580' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git format-patch upstream/pr/3580
0001-Use-gh-pr-checkout.patch
And you have a regular file (or files in case of multiple commits)
1. Store the patch in your `foreman-documentation` repository. | ||
2. Apply the patch: | ||
|
||
$ git apply proposed.patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you used git format-patch
you can use git am
which also respects the metadata in the created patch.
4. Commit the patch to your branch: | ||
|
||
$ git add guides/common/modules/X | ||
$ git commit -m "Proposed patch" | ||
|
||
To be extra nice, credit the person that provided the patch in the commit message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted before, when using git am
, it already creates the commit with proper credit (because it respects the metadata).
|
||
### Applying patches | ||
|
||
1. Store the patch in your `foreman-documentation` repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the location doesn't matter so you can say /path/to/proposed.patch
What changes are you introducing?
small introduction/docs on how to create+apply patches.
Why are you introducing these changes? (Explanation, links to references, issues, etc.)
in some PRs, it might be helpful to share patches instead of tedious suggestions on GitHub.
Anything else to add? (Considerations, potential downsides, alternative solutions you have explored, etc.)
follow-up to #3528 (review)