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

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

Open
milescrabill opened this issue Sep 16, 2024 · 4 comments
Open

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

milescrabill opened this issue Sep 16, 2024 · 4 comments
Labels
feature New feature or request github Relates to integration with GitHub gitlab Relates to integration with GitLab
Milestone

Comments

@milescrabill
Copy link

milescrabill commented Sep 16, 2024

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.
@PawelLipski
Copy link
Collaborator

Hey, thanks for the comprehensive proposal! I'm good to go with that, in fact I'm sometimes catching often doing exactly that — changing the PR title manually after amend-commits that change the PR title.

Probably the more difficult part would be to provide test coverage for the new functionality as it might require changes to the somewhat non-trivial mock GitHub/GitLab clients used in the tests — but ofc I can help with that part.

For the flag name, --update-title LGTM. I'm unsure about machete.github.prTitleMatchCommitSubject wording — maybe for more consistency with forceDescriptionFromCommitMessage it should be sth like updateTitleToCommitSubject.

As a side note, at this point, I'm feeling awkward about retarget-pr used less and less for actual retargeting of PRs, and more for updating PR descriptions 😅 probably a new subcommand like git machete github update-pr-description would make sense (ofc beyond the scope of this proposal).

@PawelLipski PawelLipski added this to the v3.30.0 milestone Sep 17, 2024
@PawelLipski PawelLipski added feature New feature or request github Relates to integration with GitHub gitlab Relates to integration with GitLab labels Sep 17, 2024
@PawelLipski
Copy link
Collaborator

Update: yeah, I'm going to add git machete github update-pr-descriptions alongside retarget-pr --updated-related-descriptions (early draft at #1343)

@PawelLipski PawelLipski modified the milestones: v3.31.0, v3.32.0 Nov 8, 2024
@PawelLipski
Copy link
Collaborator

Aaand it's ready, to be released soon 😅 you can take a look at the 3 PRs linked to the issue #1325

@milescrabill
Copy link
Author

Thank you! Sorry for not getting back to this, my personal life picked up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request github Relates to integration with GitHub gitlab Relates to integration with GitLab
Projects
None yet
Development

No branches or pull requests

2 participants