-
Notifications
You must be signed in to change notification settings - Fork 478
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
misc: Add checkout-pr.sh script for easier checkout #1947
Conversation
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.
Don't we have misc/wget-pr.sh
already?
pr_json="pr.json" | ||
|
||
curl -o $pr_json https://api.github.com/repos/namhyung/uftrace/pulls/$pr | ||
repo=$(jq -r '.head.repo.html_url' $pr_json) |
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.
What is jq
?
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 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.
You can easily understand by running the following command. It's to get the PR sender's uftrace repo.
$ curl -s https://api.github.com/repos/namhyung/uftrace/pulls/1947 | jq -r '.head.repo.html_url'
https://github.com/honggyukim/uftrace
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.
We can also get the branch name as follows.
$ curl -s https://api.github.com/repos/namhyung/uftrace/pulls/1947 | jq -r '.head.ref'
check/checkout-pr.sh
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.
That's cool. Is it ok to assume if it's installed on all modern distros?
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.
Sorry for the late answer but I guess yes.
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.
Don't we have
misc/wget-pr.sh
already?
wget-pr.sh
just downloads .patch
file, but this fetches the remote branch then checkout to it. If the PR is a bit outdated then the downloaded .patch
file can make conflicts.
Rather than this, we can just put the PR number then it will create a branch pull/<pr>
, then checkout to it and we can easily see if the branch needs rebase or not.
The usage to checkout to #1756 is as follows.
$ ./misc/checkout-pr.sh 1756
pr_json="pr.json" | ||
|
||
curl -o $pr_json https://api.github.com/repos/namhyung/uftrace/pulls/$pr | ||
repo=$(jq -r '.head.repo.html_url' $pr_json) |
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.
This might be not needed if we're working on already registered remote repos but I felt it's tedious to fetch and checkout some new contributors' branch. This script makes the workflow much easier. |
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.
Ok, I like you used git checkout -B
to create or update the branch.
163db4b
to
6fbb3cd
Compare
It usually takes some time to get patches for review but it'd be useful to have a script for that. The 'checkout-pr.sh' script accepts a single parameter to get the pull request ID. It fetches from the source repo and checkouts to the fetched head. The example usage is as follows. $ ./misc/checkout-pr.sh 1974 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 18502 100 18502 0 0 39899 0 --:--:-- --:--:-- --:--:-- 39875 remote: Enumerating objects: 1, done. remote: Counting objects: 100% (1/1), done. remote: Total 1 (delta 0), reused 1 (delta 0), pack-reused 0 (from 0) Unpacking objects: 100% (1/1), 354 bytes | 354.00 KiB/s, done. From https://github.com/GabrielKimm/uftrace * branch fix-tui-non-utf8-locale -> FETCH_HEAD Switched to and reset branch 'pull/1974' Now you're ready to review the pull request 1974 where can be found at namhyung#1974. Signed-off-by: Honggyu Kim <[email protected]>
6fbb3cd
to
e37e65a
Compare
@namhyung I've just update it so please have a look again. Thanks. |
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.
LGTM
It takes some time to get the patches for review but it'd be useful to have a script for that.
The script accepts only a parameter to get the pull request ID. It fetches from the source repo and checkouts to the fetched head.