[skara] RFR: cli: rework git-backport
Erik Helin
ehelin at openjdk.java.net
Fri Feb 19 13:56:17 UTC 2021
Hi all,
please review this patch that reworks how `git-backport` functions. `git-backport` is now much smaller (and more focused) than it used to be and now composes much better with other Skara CLI tools like `git-pr-create`. `git-backport` now simply fetches a commit from a remote repository and cherry-picks the fetched commit on top of the current branch (without committing). `git-backport` then finally makes a commit with the proper backport commit message (a commit message of the form `Backport <HASH>`).
The tool `git-backport` is now meant to be used in combination with `git-pr-create`, `git-pr-set` and `git-pr-integrate`. The following example shows how a commit can be backported, a pull request created, marking the pull request as clean and then finally integrating the pull request:
$ git checkout -b backport-5a01c3d68ac2
$ git backport --from=openjdk/jdk 5a01c3d68ac22b7ee6f0746405a9bdef43281cb7
$ git pr create
$ sleep 15 # give the bots some time to work
$ git pr set --clean
$ sleep 15 # allow the bots to do some more work
$ git pr integrate
$ git checkout -
All (or parts) of the above can of course be wrapped into a [git alias](https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases) for those that don't like to type. The following show an example alias defined in `~/.gitconfig`:
[alias]
bp = "!f() { \
git checkout -b backport-$1 && \
git backport --from=openjdk/jdk $1 && \
git pr create; \
}; f"
A user can then simply run `git bp 5a01c3d68ac22b7ee6f0746405a9bdef43281cb7`.
The `--from` parameter to `git-backport` is configurable, so a user who most likely often backports from [openjdk/jdk](https://github.com/openjdk/jdk) can run the following to never have to set `--from` on the command-line:
$ git config --global backport.from https://github.com/openjdk/jdk
Note that `git-backport` only requires a personal access token (PAT) in the case when the `--from` option contains a simple repository name, for example `jdk`. In all other cases there is no need for a PAT, making the command accessible for those who are not using PATs.
Testing:
- [x] Manual testing on Linux x64
Thanks,
Erik
-------------
Commit messages:
- cli: rework git-backport
Changes: https://git.openjdk.java.net/skara/pull/1025/files
Webrev: https://webrevs.openjdk.java.net/?repo=skara&pr=1025&range=00
Stats: 187 lines in 5 files changed: 58 ins; 92 del; 37 mod
Patch: https://git.openjdk.java.net/skara/pull/1025.diff
Fetch: git fetch https://git.openjdk.java.net/skara pull/1025/head:pull/1025
PR: https://git.openjdk.java.net/skara/pull/1025
More information about the skara-dev
mailing list