git-machete icon indicating copy to clipboard operation
git-machete copied to clipboard

Support updating PR/MR titles when retargeting a PR/MR

Open milescrabill opened this issue 1 year ago • 4 comments

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.

  • CodeHostingClient already has set_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 title string 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_request could be added, but this would mean an additional API call when restacking/retargeting.
  • The retarget_pull_request and restack_pull_request methods of MacheteClient could each take an update_title boolean 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.prTitleMatchCommitSubject and machete.gitlab.mrTitleMatchCommitSubject that controls default behavior.

milescrabill avatar Sep 16 '24 18:09 milescrabill