Skip to content

Commit

Permalink
Update multiple PR/MR descriptions in bulk (flags + subcommands)
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Oct 15, 2024
1 parent d07fbad commit a04dbdf
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 93 deletions.
63 changes: 59 additions & 4 deletions docs/man/git-machete.1
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "GIT-MACHETE" "1" "Oct 10, 2024" "" "git-machete"
.TH "GIT-MACHETE" "1" "Oct 14, 2024" "" "git-machete"
.SH NAME
git-machete \- git-machete 3.30.1
git-machete \- git-machete 3.31.0
.sp
git machete is a robust tool that \fBsimplifies your git workflows\fP\&.
.sp
Expand Down Expand Up @@ -899,7 +899,7 @@ git machete github <subcommand>
.UNINDENT
.UNINDENT
.sp
where \fB<subcommand>\fP is one of: \fBanno\-prs\fP, \fBcheckout\-prs\fP, \fBcreate\-pr\fP, \fBretarget\-pr\fP or \fBrestack\-pr\fP\&.
where \fB<subcommand>\fP is one of: \fBanno\-prs\fP, \fBcheckout\-prs\fP, \fBcreate\-pr\fP, \fBretarget\-pr\fP, \fBrestack\-pr\fP or \fBupdate\-pr\-descriptions\fP\&.
.sp
Creates, checks out and manages GitHub PRs while keeping them reflected in branch layout file.
.sp
Expand Down Expand Up @@ -998,7 +998,7 @@ Once the PR is successfully created, annotates the current branch with the new P
If \fB\&.git/info/milestone\fP file is present, its contents (a single number \-\-\- milestone id) are used as milestone.
If \fB\&.git/info/reviewers\fP file is present, its contents (one GitHub login per line) are used to set reviewers.
.sp
The subject of the first unique commit of the branch is used as PR title.
Unless \fB\-\-title\fP is provided, the subject of the first unique commit of the branch is used as PR title.
If \fB\&.git/info/description\fP or \fB\&.github/pull_request_template.md\fP template is present, its contents are used as PR description.
Otherwise (or if \fBmachete.github.forceDescriptionFromCommitMessage\fP is set), PR description is taken from message body of the first unique commit of the branch.
.sp
Expand All @@ -1016,6 +1016,10 @@ Create the new PR as a draft.
.BI \-\-title\fB= <title>
Set the PR title explicitly (the default is to use the first included commit\(aqs message as the title).
.TP
.B \-U\fP,\fB \-\-update\-related\-descriptions
Update the generated sections in related PR descriptions.
See help for \fBupdate\-pr\-descriptions \-\-related\fP below for extra considerations.
.TP
.B \-\-yes
Do not ask for confirmation whether to push the branch.
.UNINDENT
Expand All @@ -1035,6 +1039,14 @@ If the PR has been converted to draft in step 1, it\(aqs reverted to ready for r
.sp
The drafting/undrafting is useful in case the GitHub repository has set up \X'tty: link https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners'\fI\%CODEOWNERS\fP\X'tty: link'\&.
Draft PRs don\(aqt get code owners automatically added as reviewers.
.sp
\fBOptions:\fP
.INDENT 7.0
.TP
.B \-U\fP,\fB \-\-update\-related\-descriptions
Update the generated sections in related PR descriptions.
See help for \fBupdate\-pr\-descriptions \-\-related\fP below for extra considerations.
.UNINDENT
.TP
.B \fBretarget\-pr [\-b|\-\-branch=<branch>] [\-\-ignore\-if\-missing]\fP:
Sets the base of the current (or specified) branch\(aqs PR to upstream (parent) branch, as seen by git machete (see \fBgit machete show up\fP).
Expand All @@ -1052,6 +1064,10 @@ Specify the branch for which the associated PR base will be set to its upstream
.TP
.B \-\-ignore\-if\-missing
Ignore errors and quietly terminate execution if there is no PR opened for current (or specified) branch.
.TP
.B \-U\fP,\fB \-\-update\-related\-descriptions
Update the generated sections in related PR descriptions.
See help for \fBupdate\-pr\-descriptions \-\-related\fP below for extra considerations.
.UNINDENT
.TP
.B \fBsync\fP:
Expand All @@ -1069,6 +1085,29 @@ deletes untracked managed branches that have no downstream branch.
.UNINDENT
.UNINDENT
.sp
\fBupdate\-pr\-descriptions\fP:
.INDENT 0.0
.INDENT 3.5
Updates the generated sections (\(dqintro\(dq) of PR descriptions that lists the upstream and/or downstream PRs
(depending on \fBmachete.github.prDescriptionIntroStyle\fP git config key).
.sp
\fBOptions:\fP
\(em all Update PR descriptions for all PRs in the repository.
.UNINDENT
.UNINDENT
.INDENT 0.0
.INDENT 3.5
.INDENT 0.0
.TP
.B \-\-mine
Update PR descriptions for all PRs opened by the current user associated with the GitHub token.
.UNINDENT
\(em related Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch.
If \fBmachete.github.prDescriptionIntroStyle\fP is \fBup\-only\fP (default), then only downstream PR descriptions are updated.
If \fBmachete.github.prDescriptionIntroStyle\fP is \fBfull\fP, then both downstream and upstream PR descriptions are updated.
.UNINDENT
.UNINDENT
.sp
\fBGit config keys:\fP
.INDENT 0.0
.TP
Expand Down Expand Up @@ -1956,6 +1995,7 @@ by setting \fBgit config machete.status.extraSpaceBeforeBranchName true\fP\&.
git machete t[raverse] [\-F|\-\-fetch] [\-l|\-\-list\-commits] [\-M|\-\-merge]
[\-n|\-\-no\-edit\-merge|\-\-no\-interactive\-rebase] [\-\-[no\-]push] [\-\-[no\-]push\-untracked]
[\-\-return\-to=WHERE] [\-\-start\-from=WHERE] [\-\-squash\-merge\-detection=MODE]
[\-H|\-\-sync\-github\-prs|\-L|\-\-sync\-gitlab\-mrs]
[\-w|\-\-whole] [\-W] [\-y|\-\-yes]
.EE
.UNINDENT
Expand Down Expand Up @@ -2002,6 +2042,13 @@ otherwise, if the branch is behind its remote counterpart:
asks the user whether to \fBpull\fP the branch;
.UNINDENT
.IP \(bu 2
if \fB\-H\fP/\fB\-\-sync\-github\-prs\fP or \fB\-L\fP/\fB\-\-sync\-gitlab\-mrs\fP option is present:
.INDENT 2.0
.IP \(bu 2
retargets the PR/MR if it exists for the given branch and has a different base/target branch in GitHub/GitLab than the upstream in machete file,
just as \fBgit machete github retarget\-pr\fP and \fBgit machete gitlab retarget\-mr\fP would do;
.UNINDENT
.IP \(bu 2
and finally, if any of the above operations has been successfully completed:
.INDENT 2.0
.IP \(bu 2
Expand Down Expand Up @@ -2046,6 +2093,14 @@ when the current user is NOT the author of the PR/MR associated with that branch
.B \-F\fP,\fB \-\-fetch
Fetch the remotes of all managed branches at the beginning of traversal (no \fBgit pull\fP involved, only \fBgit fetch\fP).
.TP
.B \-H\fP,\fB \-\-sync\-github\-prs
Retarget the PR if it exists for the given branch and has a different base branch in GitHub than the upstream in machete file,
just as \fBgit machete github retarget\-pr\fP would do
.TP
.B \-L\fP,\fB \-\-sync\-gitlab\-mrs
Retarget the MR if it exists for the given branch and has a different target branch in GitLab than the upstream in machete file,
just as \fBgit machete gitlab retarget\-mr\fP would do
.TP
.B \-l\fP,\fB \-\-list\-commits
When printing the status, additionally list the messages of commits introduced on each branch.
.TP
Expand Down
40 changes: 33 additions & 7 deletions docs/source/cli/github.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ github
git machete github <subcommand>
where ``<subcommand>`` is one of: ``anno-prs``, ``checkout-prs``, ``create-pr``, ``retarget-pr`` or ``restack-pr``.
where ``<subcommand>`` is one of: ``anno-prs``, ``checkout-prs``, ``create-pr``, ``retarget-pr``, ``restack-pr`` or ``update-pr-descriptions``.

Creates, checks out and manages GitHub PRs while keeping them reflected in branch layout file.

Expand Down Expand Up @@ -83,7 +83,7 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc
If ``.git/info/milestone`` file is present, its contents (a single number --- milestone id) are used as milestone.
If ``.git/info/reviewers`` file is present, its contents (one GitHub login per line) are used to set reviewers.

The subject of the first unique commit of the branch is used as PR title.
Unless ``--title`` is provided, the subject of the first unique commit of the branch is used as PR title.
If ``.git/info/description`` or ``.github/pull_request_template.md`` template is present, its contents are used as PR description.
Otherwise (or if ``machete.github.forceDescriptionFromCommitMessage`` is set), PR description is taken from message body of the first unique commit of the branch.

Expand All @@ -94,11 +94,14 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc

**Options:**

--draft Create the new PR as a draft.
--draft Create the new PR as a draft.

--title=<title> Set the PR title explicitly (the default is to use the first included commit's message as the title).
--title=<title> Set the PR title explicitly (the default is to use the first included commit's message as the title).

--yes Do not ask for confirmation whether to push the branch.
-U, --update-related-descriptions Update the generated sections in related PR descriptions.
See help for ``update-pr-descriptions --related`` below for extra considerations.

--yes Do not ask for confirmation whether to push the branch.

``restack-pr``:
Perform the following sequence of actions:
Expand All @@ -111,6 +114,11 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc
The drafting/undrafting is useful in case the GitHub repository has set up `CODEOWNERS <https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners>`_.
Draft PRs don't get code owners automatically added as reviewers.

**Options:**

-U, --update-related-descriptions Update the generated sections in related PR descriptions.
See help for ``update-pr-descriptions --related`` below for extra considerations.

``retarget-pr [-b|--branch=<branch>] [--ignore-if-missing]``:
Sets the base of the current (or specified) branch's PR to upstream (parent) branch, as seen by git machete (see ``git machete show up``).

Expand All @@ -121,9 +129,12 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc

**Options:**

-b, --branch=<branch> Specify the branch for which the associated PR base will be set to its upstream (parent) branch. The current branch is used if the option is absent.
-b, --branch=<branch> Specify the branch for which the associated PR base will be set to its upstream (parent) branch. The current branch is used if the option is absent.

--ignore-if-missing Ignore errors and quietly terminate execution if there is no PR opened for current (or specified) branch.

--ignore-if-missing Ignore errors and quietly terminate execution if there is no PR opened for current (or specified) branch.
-U, --update-related-descriptions Update the generated sections in related PR descriptions.
See help for ``update-pr-descriptions --related`` below for extra considerations.

``sync``:
**Deprecated.** Use ``github checkout-prs --mine``, ``delete-unmanaged`` and ``slide-out --removed-from-remote``.
Expand All @@ -135,6 +146,21 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc
#. deletes unmanaged branches,
#. deletes untracked managed branches that have no downstream branch.

``update-pr-descriptions``:

Updates the generated sections ("intro") of PR descriptions that lists the upstream and/or downstream PRs
(depending on ``machete.github.prDescriptionIntroStyle`` git config key).

**Options:**

--all Update PR descriptions for all PRs in the repository.

--mine Update PR descriptions for all PRs opened by the current user associated with the GitHub token.

--related Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch.
If ``machete.github.prDescriptionIntroStyle`` is ``up-only`` (default), then only downstream PR descriptions are updated.
If ``machete.github.prDescriptionIntroStyle`` is ``full``, then both downstream and upstream PR descriptions are updated.

**Git config keys:**

``machete.github.{domain,remote,organization,repository}`` (all subcommands):
Expand Down
Loading

0 comments on commit a04dbdf

Please sign in to comment.