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

Add a --dry-run option #13

Closed
wants to merge 1 commit into from
Closed

Conversation

ncoghlan
Copy link
Contributor

  • still fetches upstream changes
  • otherwise just prints commands that would be executed if
    everything runs without errors
  • also prints the PR creation URLs that would be opened
  • does NOT do any local checkouts, cherry-picks, branch
    creation or branch deletion
  • does NOT actually create any PRs

Side effect: handles the cases where the remote to push to is
called 'pr' and/or is checked out over SSH rather than HTTPS.

Side effect: adds a "backport-" prefix to the cherry-pick branches

- still fetches upstream changes
- otherwise just prints commands that would be executed if
  everything runs without errors
- also prints the PR creation URLs that would be opened
- does NOT do any local checkouts, cherry-picks, branch
  creation or branch deletion
- does NOT actually create any PRs

Side effect: handles the cases where the remote to push to is
called 'pr' and/or is checked out over SSH rather than HTTPS.

Side effect: adds a "backport-" prefix to the cherry-pick branches
@ncoghlan
Copy link
Contributor Author

My git setup is somewhat different from yours (origin+pr as remotes, pr accessed over ssh rather than HTTPS), so I added a new dryrun option to figure out the details of the differences.

There's one purely cosmetic change mixed in here, which was to add a "backport-" prefix to the branch names, as I found that easier to read in dryrun mode (vs the full hash on the cherry-pick lines), as well as making the branch names more self-explanatory.

Copy link
Owner

@Mariatta Mariatta left a comment

Choose a reason for hiding this comment

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

Thanks @ncoghlan ! I like this idea! I left some comments :)

@@ -5,16 +5,22 @@


@click.command()
@click.option('--dryrun', is_flag=True)
Copy link
Owner

Choose a reason for hiding this comment

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

Just minor nitpick, can we use --dry_run instead of --dryrun? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you be OK with --dry-run? That will still give dry_run as the parameter name, and make the CLI spelling consistent with other tools like git and behave.

return username


def run_cmd(cmd):
def run_cmd(cmd, *, dryrun=False):
Copy link
Owner

Choose a reason for hiding this comment

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

nitpick, dry_run=False instead of dryrun=False


In case of merge conflicts or errors, then... the script will fail :stuck_out_tongue:

Passing the `--dryrun` option will cause the script to print out all the
Copy link
Owner

Choose a reason for hiding this comment

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

Let's add this to line 3
e.g.

python -m cherry_picker <commit_sha1> <branches> [--dry_run]

and maybe line 52?

@@ -62,20 +69,27 @@ What this will do:

(venv) $ git fetch upstream

(venv) $ git checkout -b 6de2b78-3.5 upstream/3.5
(venv) $ git checkout -b backport-6de2b78-3.5 upstream/3.5
Copy link
Owner

Choose a reason for hiding this comment

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

Please update the url in line 102
with

https://github.com/python/cpython/compare/3.5...Mariatta:backport-6de2b78-3.5?expand=1

"""
cmd = "git remote get-url pr"
if run_cmd(cmd, dryrun=False):
return "pr"
Copy link
Owner

Choose a reason for hiding this comment

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

How common is this "origin/pr" pattern?
I wanted the script to be as simple and straight-forward as possible, but perhaps the way to approach this is to pass it as a command line option.
eg. cherry_picker sha branches [--dry_run] [--push=pr]

if --push is not passed, then we'll use origin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually learned origin/pr before upstream/origin, as the expected pattern was that you'd have a read-only clone of upstream first, and only decide to submit PRs later.

I like the "--push" CLI option though, leaving the automated guess solely for the upstream vs origin case.

@ncoghlan
Copy link
Contributor Author

Your suggested fixes all make sense to me, so there's just the --dry_run vs --dry-run question before I update the PR.

@Mariatta
Copy link
Owner

--dry-run works :) Thanks.

@Mariatta
Copy link
Owner

Please re-open the PR in core-workflow repo :) Thanks.

@ncoghlan ncoghlan changed the title Add a --dryrun option Add a --dry-run option Mar 18, 2017
@Mariatta Mariatta closed this Mar 18, 2017
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

2 participants