Skip to content

Apply a Pull Request

Amat Martínez edited this page May 6, 2019 · 4 revisions

Usage

$> sastre deploy --help
Usage: deploy [OPTIONS]

Options:
  --pr TEXT              Pull request to apply  [required]
  --host TEXT            Host to apply  [required]
  --from-number INTEGER  From commit number
  --from-commit TEXT     From commit hash (included)
  --force-hostname TEXT  Force hostname  [default: False]
  --owner TEXT           GitHub owner name  [default: gisce]
  --repository TEXT      GitHub repository name  [default: erp]
  --src TEXT             Remote src path  [default: /home/erp/src]
  --help                 Show this message and exit.

$> sastre deploy --pr <pr_number> --host ssh://<user>@<hostname>

Manual Resolve

Applying a PR may involve a conflicting PR. Applying such PRs will require manual resolves to merge the conflicts.

The Apply PR command will apply the commits until the conflicting patch is found. Then the user must solve the conflicts manually.

Apply PR command is based on the git am command (you can get more info here), which creates an "am" session, applying patch by patch until a conflicting patch is found.

Manual resolve conflicting patch

One of the best practices to apply it is to get the reject file (with the patches that won't apply directly). To do so:

  1. Go to the affected server (via ssh)

  2. Apply the patch with the following command:

    git apply --reject patches/<pr_number>/<conflicting_patch>

  3. Solve the conflits by reading the "*.rej" files and updating the affected file manually with an editor (like vim)

  4. Add the commit files (even if no "*.rej" was generated), we recommend using the "--patch" to add only the changes from the commit if the file isn't clean on the repository before applying.

  5. Go back to your applying session and insert a return character (press Intro) to resume.

Skip a conflicting patch

On the Apply_pr session, insert a return character (press Intro) to skip the current commit.

Applying session lost

Either the connection was lost or you, as a user, killed it on your PC the remote session will be kept. Also if the session was lost unexpectedly it won't be maked as Failed or Deployed on GitHub.

For a correct usage of deploy marks on github, it'd be great to mark as Failed or Deployed using status_pr

Also remember to enter the affected server (via ssh) and abort the current am session (initiated with apply_pr, but never closed)

# Status will show if the repository is applying patches inside an "am" session
git status
# You can abort the current AM session restoring all files as they where,
# but beware the edited files as they won't be restored
git am --abort