-
Notifications
You must be signed in to change notification settings - Fork 2k
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
dist/tools: Add script for backporting PR's #8968
Conversation
Thank you, I sadly never came to doing that :( |
Not tested yet. It would be really cool to use it and test for this release. As discussed irl, I would prefer some subfunctions to split the tasks, as you say there is "fetch", "create worktree", "cherry-pick", "publish PR". Also maybe separate strings operation/sorting and things on github object. Right now, as most part of the code is below the
We can spend some time together on it and write a user doc. |
Added noop mode to the todo list after some offline discussion |
I tried it (and felt reckless). Some issues:
Next problem:
I stopped here for now. This is on Arch Linux with python 3.6. |
Thanks for testing, will fix |
Ah, manually selecting a branch is not really well supported yet, by default it selects the latest release by sorting them numerically 😨 |
Can't you catch the 404 and print a help message regarding that? |
Yes of course, I'm a bit dissapointed in that a 404 is returned and not a 403, but they probably have a good reason for that. |
Most likely object obfuscation. It's in general safer (against brute force attacks) to pretend a resource does not exist than to reveal, that it does but that the requester has no permission to read it. |
Summary of the irl discussion on changes I would be interested in. Add informations on getting the tokenGithub->Settings->Developper settings->Personal access tokens->Generate New Only following scope is required
Name it, generate and save it to ~/.githubtoken (warning you cannot see it later anymore). --gitdir
--comment
Separating stepsInstead of a "--noop", I am interested in having separate steps so I can review them:
|
I forgot that to make it work, I disabled this line in my config
It was pushing to |
For the push default the following patch made it work:
|
@cladmi Thanks for investigating! |
Please make the script executable. |
Some more remarks:
|
(minor nit: I think the name |
If a less generic name is preferred, I'd rather name it something with riot in the name:
Should be fixed.
Not sure why. I'd have to investigate this, the notification means that for some reason the pull request could not be created, but this could be anything. |
👍 |
Fixed-up the new label for "backporting-needed" #9591 (comment) |
Renamed the token file. |
Some doc which permissions are required for the token would be nice ;-). |
The |
If we start looking into the script quality, I would also point the
And enable the
So we could still refine the script I guess. |
b94e5ed
to
04cf4d6
Compare
I noticed I rebased on a old master, so just rebased on a new one. |
Why rebase at all if there is no conflict ;-)? |
I wanted to be based on the branch where |
Tox? |
Before somebody gets crazy when refactoring into functions the |
I've also noticed this once. The whole |
Why would not a getter be allowed to modify an object? I think it is a really nice design pattern >< |
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 means re-ACK. @cladmi addressed my change request and added tox support since then, so nothing was drastically changed)
(+ I just re-tested this script by opening #10954 ;-)) |
if not pulldata['merged']: | ||
print("Original PR not yet merged") | ||
exit(0) | ||
print("Fetching for commit: #{}: {}".format(args.PR, pulldata['title'])) |
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.
One thing I noticed here: if I have a multi-line commit message it shows the whole message, not just the summary line.
Ping for squashing btw. |
This script provides functionality to easily backport a merged pull request to a release branch. It relies of having a `github` API token stored in `~/.riotgithubtoken` by default. The script works by fetching information from the supplied **merged** pull request. It then looks for the last release branch. A temporary git `worktree` with a new branch is created based on this release branch. All commits from the pull request are then cherry-picked into this branch which is then pushed to `origin`. It then creates a new pull request on `github` with a reference to the original pull request. It optionally puts a comment under the original pull request to the new backport pull request. Co-authored-by: Gaëtan Harter <[email protected]>
Adapt tox file from `compile_and_test_for_board.py`. `tox` is still not working without errors but gives way to start refactoring.
c99f6a8
to
9af491d
Compare
I squashed and rebased. I in-lined a fix for The |
Ok, let's fix those in follow-ups. |
@cladmi Thank you for managing this PR! |
@bergzand you wrote all the logic, I only handled the fiddling which was easier :) |
So thanks to you ! |
Contribution description
This python script provides functionality to easily backport a merged PR to a release.
It relies on having a github API token stored locally to authenticate against github, by default it looks into
~/.githubtoken
~/.riotgithubtoken
, but this is configurable.The script works by fetching information from the supplied (merged) PR. It then looks for the latest release branch. A temporary worktree with a new branch checked out is created based on this release branch. All commit from the PR are then cherry picked into the worktree and the new branch is pushed to
origin
. It then creates a new pull request with a reference to the old PR on github and optionally puts a comment under the old PR with a reference to the new backport PR.I haven't been able to test the last few lines of the script (creating the PR and placing the comment) as I did not want to create new backport PR's for 2018.01 :)
Issues/PRs references
#8523
TODO: