Skip to content
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

Create retarget-open-prs utility #45230

Merged
merged 11 commits into from
Sep 4, 2020
Merged

Create retarget-open-prs utility #45230

merged 11 commits into from
Sep 4, 2020

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented Aug 26, 2020

Changes proposed in this Pull Request

  • Add utility retarget-open-prs that retargets open pull requests in a repository from one branch to another

Testing instructions

  • Open a PR in a repository you own against a test branch, then run the utility using a strictly scoped access token to retarget the PR to a different branch.

Related to #43395

@sarayourfriend sarayourfriend added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Aug 26, 2020
@sarayourfriend sarayourfriend requested review from scinos and a team August 26, 2020 18:46
@matticbot
Copy link
Contributor

@sarayourfriend sarayourfriend changed the title Add/retarget open prs Create retarget-open-prs utility Aug 26, 2020
@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with this one @saramarcondes!

I'll let @scinos to provide his feedback, but I'm leaving some thoughts and questions, none of which are really blocking IMHO. It mostly depends on how much we want to focus on making this one error-proof from the first iteration 😉

} );

if ( remainingRateLimit === 0 ) {
const rateLimitResetDate = new Date( rateLimitReset * 1000 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could just make the script wait for that time instead? That way we won't have to execute it again, but we can just wait for it to restart automatically once rate limit is reset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The amount of time I'm observing locally can be up to an hour, which seems like an awful long time for a script to stall. Do you think we should determine a tolerance? Maybe if the time is within the next ~minute or so we wait but otherwise escape with the message?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the thing, maybe I want the script to run in the background while I'm working on other things 😉

We could have a config flag for that, and keep the default behavior as you described. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me!

packages/retarget-open-prs/index.js Outdated Show resolved Hide resolved
packages/retarget-open-prs/index.js Outdated Show resolved Hide resolved
packages/retarget-open-prs/index.js Outdated Show resolved Hide resolved
packages/retarget-open-prs/index.js Outdated Show resolved Hide resolved
describe:
'The original branch name against which to select open PRs that need to be retargted.',
demandOption: true,
requiresArg: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it makes sense to always default to the default branch here? We could fetch it from the default_branch field at https://docs.github.com/en/rest/reference/repos#get-a-repository

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are your thoughts on this @saramarcondes? Perhaps this suggestion would be over-engineering, but I was just curious to know what you think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about doing this but it didn't feel necessary for something that could be too easily unintentional depending on the use case. It doesn't save but 10 keystrokes in most cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

packages/retarget-open-prs/README.md Outdated Show resolved Hide resolved
packages/retarget-open-prs/cli.js Outdated Show resolved Hide resolved
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is looking great to me 👍 Nice work with this @saramarcondes! I don't see anything preventing this PR from shipping at this point.

@scinos did you have any further thoughts on this PR? I'd love to get your expertised mind to provide some feedback, if possible 😉

packages/retarget-open-prs/README.md Outdated Show resolved Hide resolved
Co-authored-by: Marin Atanasov <8436925+tyxla@users.noreply.github.com>
@sarayourfriend sarayourfriend merged commit dbea4ed into master Sep 4, 2020
@sarayourfriend sarayourfriend deleted the add/retarget-open-prs branch September 4, 2020 16:36
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants