Skip to content

Instantly share code, notes, and snippets.

@jturel
Last active July 23, 2021 17:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jturel/3095c0d7b51205c29f98b42838168862 to your computer and use it in GitHub Desktop.
Save jturel/3095c0d7b51205c29f98b42838168862 to your computer and use it in GitHub Desktop.
Testing PRs in a production environment

Two options

  1. Add the github or gitlab repo as a remote and cherry-pick the PR on top. Good for large PRs with multiple commits that you may wish to apply independently or omit completely.
  2. Use curl to download the patch file from the PR. Good for small PRs!

Steps

Find the katello source code location and cd into it:

rpm -ql tfm-rubygem-katello | head
cd /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.18.1.31

Initialize a git repository so it's easy to revert code changes

git init
git add -A
git commit -m "initial"

If testing a large PR add the gitlab or github repo and create a branch for it:

git remote add upstream https://github.com/katello/katello
git fetch upstream pull/PULL_REQUEST_ID/head:SOME_LOCAL_BRANCH_NAME

cherry-pick the code change onto the working branch:

git cherry-pick SOME_LOCAL_BRANCH_NAME

You may need to resolve merge conflicts. Ignore any test/ files - they aren't going to affect anything.

Restart the server to make the changes visible:

systemctl restart httpd foreman smart_proxy_dynflow_core

If testing a small PR download the .patch via curl and apply it to the code

curl -skiL https://github.com/Katello/katello/pull/9467.patch -o 9467.patch
git apply --reject --whitespace=fix 9467.patch

Any merge conflicts will be created in files with the .rej extension. Resolve them manually.

Another alternative is to download the raw file directly from the PR and put them in the right place with curl. Good for single-file changes. The URL is taken from the Files view on the PR, viewing the individual file, and pressing the 'Raw' button.

https://raw.githubusercontent.com/Katello/katello/ec40908addd2d0befc53e6d2d6220e6a2a503e06/app/lib/actions/candlepin/environment/create.rb -o app/lib/actions/candlepin/environment/create.rb

Restart the server to make the changes visible

systemctl restart foreman httpd smart_proxy_dynflow_core
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment