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

Explain how to work with patches #3580

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maximiliankolb
Copy link
Contributor

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)

Copy link

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:

show diff

show diff as HTML

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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


1. Fetch the PR from GitHub:

$ git fetch upstream pull/1234/head:pr_1234_optional_description
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.

Comment on lines +121 to +126
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.
Copy link
Member

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.
Copy link
Member

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

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