git-machete
git-machete copied to clipboard
Support updating PR/MR titles when retargeting a PR/MR
git-machete enables a lot of workflows, but for mine in particular I often have single-commit GitHub PRs stacked on top of each other. It would be very convenient if git-machete {restack,retarget} could keep the titles of the PRs in sync with the corresponding commit subject if it changes.
I would like to be able to configure git-machete to manage PR/MR titles for me when restacking or retargeting PR/MRs. When creating a PR/MR using {create-pr,create-mr}, by default the commit message subject of the first commit after the fork point is used as the PR/MR title.
#1325 covers updating PR/MR descriptions with a flag like --update-all-descriptions to {create,restack,retarget}-{mr,pr}. In the same vein, I propose the flags --update-title and --update-all-titles. There could be an option to make this the default behavior for GitHub / GitLab respectively as well. I would wait to see how --update-all-descriptions is implemented before attempting --update-all-titles.
I'm happy to take this on, but I'd like to get some pre-feedback to understand if this proposal is in line with the goals of the project. Here are some ideas for implementation. I'm sure there are better approaches that I haven't thought of, so please feel free to correct me.
CodeHostingClientalready hasset_description_of_pull_request, and the scenarios in which a PR/MR title is being updated are the same as when the description would be updated.- Both GitHub and GitLab support simply passing a
titlestring alongside the description string in the{PATCH,PUT}request that updates the PR/MR. - This method could be extended and renamed and additionally set the title.
- Alternatively, a new function
set_title_of_pull_requestcould be added, but this would mean an additional API call when restacking/retargeting.
- Alternatively, a new function
- Both GitHub and GitLab support simply passing a
- The
retarget_pull_requestandrestack_pull_requestmethods ofMacheteClientcould each take anupdate_titleboolean which when set would pass the commit message subject of the first commit after the fork point as the title to update.- These methods could additionally look at a configuration value
machete.github.prTitleMatchCommitSubjectandmachete.gitlab.mrTitleMatchCommitSubjectthat controls default behavior.
- These methods could additionally look at a configuration value