python/cherry-picker

Loss of title and description when doing `cherry_picker --continue`

brettcannon opened this issue · 7 comments

Maybe I'm doing something wrong, but when I have used cherry_picker --continue I inevitably lose the title and description I would have ended up with had there not been any merge conflict. Not sure if there's any way to prevent that or to output what the message would have been so I can copy-and-paste it into the eventual PR?

This happened to me when I did git commit manually after resolving conflicts.

@brettcannon Did you use --continue after a merge conflict, or after using --no-push?
And did you have additional commit?

In @serhiy-storchaka's situation, when there are more than one commits in a branch, GitHub will prepopulate the PR title with the branch name. Is this what you meant by losing the title and description?

One way to solve this is to have cherry_picker create the PR using GitHub API / gidgethub, where we can specify the PR title and description ourselves instead of relying on GitHub web UI.

Printing out the original commit message for copy-pasting is the easy way out for now 😛

In PR #109 the commit message is printed out so you can copy-paste.

@Mariatta it was with --continue after dealing with a merge conflict.

This may also align with #107, which we're pretty sure will need a "persistent scratch-pad" where cherry-picker can leave notes for itself in order to remember the original command line options for use with --continue.

Probably the simplest option for that would be a JSON file with a config dictionary in it, but if we made it officially an opaque format (e.g. .cherry-pick.state), then it could potentially be switched to a full pickle with shelve at a later date (and either way it would be easy for other commands to detect that a previous cherry-pick was still in progress due to the state file being present).

Now with the work done in #295/#277 it should possible to implements storing more state-related data in git config --local (i.e. .git/config) throughout the whole backport cycle.

I also ran into the same issue recently when manually fixing some conflicts. I just want to point out that it is now apparently possible to supply the title and description (as Mariatta suggested originally) inside the query string of the Github PR url i.e. github.com/.../compare/...?title=PR title&body=PR description. This will prefill the values automatically when opening the page in the browser.

We could just add the title and description to this url:

def get_pr_url(self, base_branch, head_branch):
return f"https://github.com/{self.config['team']}/{self.config['repo']}/compare/{base_branch}...{self.username}:{head_branch}?expand=1"