Skip to content

Commit 140e278

Browse files
committed
Add --by=... flag to git machete git{hub,lab} --update-{pr,mr}-descriptions
1 parent e4ec3d9 commit 140e278

17 files changed

+107
-48
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ However, we still recommend using merge for the narrow case of [backporting hotf
255255

256256
<br/>
257257

258+
#### In what order should I merge stacked PRs?
259+
260+
We recommend merging PRs from the top-most (closest to the root branch, typically `main` or `master`).
261+
In other words, PR should only be merged when its base is a root branch.
262+
263+
This way, you don't end up with a big-ball-of-code PR at the end.
264+
Avoid such balls is one of the main reasons for opening small PRs in the first place.
265+
266+
<br/>
267+
258268
#### Sometimes when I run `update` or `traverse`, too many commits are taken into the rebase... how to fix that?
259269

260270
Contrary to the popular misconception, git doesn't have a notion of

RELEASE_NOTES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Release notes
22

3-
## New in git-machete 3.32.2
3+
## New in git-machete 3.33.0
4+
5+
- added: `--by=...` flag to `git machete git{hub,lab} update-{pr,mr}-descriptions`
46

57
## New in git-machete 3.32.1
68

completion/git-machete.completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ _git_machete() {
2727
local githublab_checkout_opts="--all --by= --mine"
2828
local githublab_restack_opts="-U --update-related-descriptions"
2929
local githublab_retarget_opts="-b --branch= --ignore-if-missing -U --update-related-descriptions"
30-
local githublab_update_descriptions_opts="--all --mine --related"
30+
local githublab_update_descriptions_opts="--all --by= --mine --related"
3131
local reapply_opts="-f --fork-point="
3232
local slide_out_opts="-d --down-fork-point= --delete -M --merge -n --no-edit-merge --no-interactive-rebase --removed-from-remote"
3333
local squash_opts="-f --fork-point="

completion/git-machete.completion.zsh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ __git_machete_github_subcommands() {
304304
(update-pr-descriptions)
305305
_arguments \
306306
'(--all)'--all'[Update PR descriptions for all PRs in the repository]' \
307+
'(--by)'--by='[Update PR descriptions for all PRs authored by the given GitHub user]' \
307308
'(--mine)'--mine'[Update PR descriptions for all PRs opened by the current user associated with the GitHub token]' \
308309
'(--related)'--related'[Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch]' \
309310
"${common_flags[@]}"
@@ -379,6 +380,7 @@ __git_machete_gitlab_subcommands() {
379380
(update-mr-descriptions)
380381
_arguments \
381382
'(--all)'--all'[Update MR descriptions for all MRs in the project]' \
383+
'(--by)'--by='[Update MR descriptions for all MRs authored by the given GitLab user]' \
382384
'(--mine)'--mine'[Update MR descriptions for all MRs opened by the current user associated with the GitLab token]' \
383385
'(--related)'--related'[Update MR descriptions for all MRs that are upstream and/or downstream of the MR for the current branch]' \
384386
"${common_flags[@]}"

completion/git-machete.fish

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ complete -c git-machete -n "__fish_seen_subcommand_from github; and not __fish_s
103103
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from anno-prs; and not __fish_seen_subcommand_from --with-urls" -f -l with-urls -d 'Include PR URLs in the annotations'
104104
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from checkout-prs; and not __fish_seen_subcommand_from --all" -f -l all -d 'Checkout all open PRs'
105105
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from checkout-prs; and not __fish_seen_subcommand_from --by" -x -l by -d "Checkout someone's open PRs"
106-
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from checkout-prs; and not __fish_seen_subcommand_from --mine" -x -l mine -d 'Checkout open PRs for the current user associated with the GitHub token'
106+
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from checkout-prs; and not __fish_seen_subcommand_from --mine" -f -l mine -d 'Checkout open PRs for the current user associated with the GitHub token'
107107
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from create-pr; and not __fish_seen_subcommand_from --draft" -f -l draft -d 'Create the new PR as a draft'
108108
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from create-pr; and not __fish_seen_subcommand_from --title" -x -l title -d 'Set the title for new PR explicitly'
109109
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from create-pr; and not __fish_seen_subcommand_from --update-related-descriptions" -f -l update-related-descriptions -s U -d 'Update the generated sections of PR descriptions that list the upstream and/or downstream PRs'
@@ -113,8 +113,9 @@ complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_
113113
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from retarget-pr; and not __fish_seen_subcommand_from --ignore-if-missing" -f -l ignore-if-missing -d 'Ignore errors and quietly terminate execution if there is no PR opened for current (or specified) branch'
114114
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from retarget-pr; and not __fish_seen_subcommand_from --update-related-descriptions" -f -l update-related-descriptions -s U -d 'Update the generated sections of PR descriptions that list the upstream and/or downstream PRs'
115115
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from update-pr-descriptions; and not __fish_seen_subcommand_from --all" -f -l all -d 'Update PR descriptions for all PRs in the repository'
116-
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from update-pr-descriptions; and not __fish_seen_subcommand_from --mine" -x -l mine -d 'Update PR descriptions for all PRs opened by the current user associated with the GitHub token'
117-
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from update-pr-descriptions; and not __fish_seen_subcommand_from --related" -x -l related -d 'Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch'
116+
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from update-pr-descriptions; and not __fish_seen_subcommand_from --by" -x -l by -d 'Update PR descriptions for all PRs opened by the given user'
117+
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from update-pr-descriptions; and not __fish_seen_subcommand_from --mine" -f -l mine -d 'Update PR descriptions for all PRs opened by the current user associated with the GitHub token'
118+
complete -c git-machete -n "__fish_seen_subcommand_from github; and __fish_seen_subcommand_from update-pr-descriptions; and not __fish_seen_subcommand_from --related" -f -l related -d 'Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch'
118119

119120
# git machete gitlab
120121
complete -c git-machete -n "not __fish_seen_subcommand_from $__machete_commands" -f -a gitlab -d 'Create, check out and manage GitLab MRs while keeping them reflected in git machete'
@@ -127,7 +128,7 @@ complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and not __fish_s
127128
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from anno-mrs; and not __fish_seen_subcommand_from --with-urls" -f -l with-urls -d 'Include MR URLs in the annotations'
128129
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from checkout-mrs; and not __fish_seen_subcommand_from --all" -f -l all -d 'Checkout all open MRs'
129130
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from checkout-mrs; and not __fish_seen_subcommand_from --by" -x -l by -d "Checkout someone's open MRs"
130-
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from checkout-mrs; and not __fish_seen_subcommand_from --mine" -x -l mine -d 'Checkout open MRs for the current user associated with the GitLab token'
131+
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from checkout-mrs; and not __fish_seen_subcommand_from --mine" -f -l mine -d 'Checkout open MRs for the current user associated with the GitLab token'
131132
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from create-mr; and not __fish_seen_subcommand_from --draft" -f -l draft -d 'Create the new MR as a draft'
132133
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from create-mr; and not __fish_seen_subcommand_from --title" -x -l title -d 'Set the title for new MR explicitly'
133134
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from create-mr; and not __fish_seen_subcommand_from --update-related-descriptions" -f -l update-related-descriptions -s U -d 'Update the generated sections of MR descriptions that list the upstream and/or downstream MRs'
@@ -137,8 +138,9 @@ complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_
137138
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from retarget-mr; and not __fish_seen_subcommand_from --ignore-if-missing" -f -l ignore-if-missing -d 'Ignore errors and quietly terminate execution if there is no MR opened for current (or specified) branch'
138139
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from retarget-mr; and not __fish_seen_subcommand_from --update-related-descriptions" -f -l update-related-descriptions -s U -d 'Update the generated sections of MR descriptions that list the upstream and/or downstream MRs'
139140
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from update-mr-descriptions; and not __fish_seen_subcommand_from --all" -f -l all -d 'Update MR descriptions for all MRs in the project'
140-
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from update-mr-descriptions; and not __fish_seen_subcommand_from --mine" -x -l mine -d 'Update MR descriptions for all MRs opened by the current user associated with the GitHub token'
141-
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from update-mr-descriptions; and not __fish_seen_subcommand_from --related" -x -l related -d 'Update MR descriptions for all MRs that are upstream and/or downstream of the MR for the current branch'
141+
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from update-mr-descriptions; and not __fish_seen_subcommand_from --by" -f -l by -d 'Update MR descriptions for all MRs opened by the given user'
142+
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from update-mr-descriptions; and not __fish_seen_subcommand_from --mine" -f -l mine -d 'Update MR descriptions for all MRs opened by the current user associated with the GitHub token'
143+
complete -c git-machete -n "__fish_seen_subcommand_from gitlab; and __fish_seen_subcommand_from update-mr-descriptions; and not __fish_seen_subcommand_from --related" -f -l related -d 'Update MR descriptions for all MRs that are upstream and/or downstream of the MR for the current branch'
142144

143145
# git machete go
144146
complete -c git-machete -n "not __fish_seen_subcommand_from $__machete_commands" -f -a go -d 'Check out the branch relative to the position of the current branch, accepts down/first/last/next/root/prev/up argument'

docs/man/git-machete.1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
2727
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
2828
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
2929
..
30-
.TH "GIT-MACHETE" "1" "Feb 07, 2025" "" "git-machete"
30+
.TH "GIT-MACHETE" "1" "Feb 18, 2025" "" "git-machete"
3131
.SH NAME
32-
git-machete \- git-machete 3.32.2
32+
git-machete \- git-machete 3.33.0
3333
.sp
3434
git machete is a robust tool that \fBsimplifies your git workflows\fP\&.
3535
.sp
@@ -1090,7 +1090,7 @@ deletes unmanaged branches,
10901090
deletes untracked managed branches that have no downstream branch.
10911091
.UNINDENT
10921092
.TP
1093-
.B \fBupdate\-pr\-descriptions\fP:
1093+
.B \fBupdate\-pr\-descriptions [\-\-all | \-\-by=<github\-login> | \-\-mine | \-\-related]\fP:
10941094
Updates the generated sections (\(dqintros\(dq) of PR descriptions that list the upstream and/or downstream PRs
10951095
(depending on \fBmachete.github.prDescriptionIntroStyle\fP git config key).
10961096
.sp
@@ -1100,6 +1100,9 @@ Updates the generated sections (\(dqintros\(dq) of PR descriptions that list the
11001100
.B \-\-all
11011101
Update PR descriptions for all PRs in the repository.
11021102
.TP
1103+
.BI \-\-by\fB= <github\-login>
1104+
Update PR descriptions for all PRs authored by the given GitHub user, where \fB<github\-login>\fP is the GitHub account name.
1105+
.TP
11031106
.B \-\-mine
11041107
Update PR descriptions for all PRs opened by the current user associated with the GitHub token.
11051108
.TP
@@ -1351,7 +1354,7 @@ Update the generated sections (\(dqintros\(dq) of MR descriptions that list the
13511354
See help for \fBgit machete gitlab update\-mr\-descriptions \-\-related\fP for details.
13521355
.UNINDENT
13531356
.TP
1354-
.B \fBupdate\-mr\-descriptions\fP:
1357+
.B \fBupdate\-mr\-descriptions [\-\-all | \-\-by=<gitlab\-login> | \-\-mine | \-\-related]\fP:
13551358
Updates the generated sections (\(dqintros\(dq) of MR descriptions that list the upstream and/or downstream MRs
13561359
(depending on \fBmachete.gitlab.mrDescriptionIntroStyle\fP git config key).
13571360
.sp
@@ -1361,6 +1364,9 @@ Updates the generated sections (\(dqintros\(dq) of MR descriptions that list the
13611364
.B \-\-all
13621365
Update MR descriptions for all MRs in the project.
13631366
.TP
1367+
.BI \-\-by\fB= <gitlab\-login>
1368+
Update MR descriptions for all MRs authored by the given GitLab user, where \fB<gitlab\-login>\fP is the GitLab account name.
1369+
.TP
13641370
.B \-\-mine
13651371
Update MR descriptions for all MRs opened by the current user associated with the GitLab token.
13661372
.TP

docs/source/cli/github.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,21 @@ Creates, checks out and manages GitHub PRs while keeping them reflected in branc
146146
#. deletes unmanaged branches,
147147
#. deletes untracked managed branches that have no downstream branch.
148148

149-
``update-pr-descriptions``:
149+
``update-pr-descriptions [--all | --by=<github-login> | --mine | --related]``:
150150
Updates the generated sections ("intros") of PR descriptions that list the upstream and/or downstream PRs
151151
(depending on ``machete.github.prDescriptionIntroStyle`` git config key).
152152

153153
**Options:**
154154

155-
--all Update PR descriptions for all PRs in the repository.
155+
--all Update PR descriptions for all PRs in the repository.
156156

157-
--mine Update PR descriptions for all PRs opened by the current user associated with the GitHub token.
157+
--by=<github-login> Update PR descriptions for all PRs authored by the given GitHub user, where ``<github-login>`` is the GitHub account name.
158158

159-
--related Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch.
160-
If ``machete.github.prDescriptionIntroStyle`` is ``up-only`` (default), then only downstream PR descriptions are updated.
161-
If ``machete.github.prDescriptionIntroStyle`` is ``full``, then both downstream and upstream PR descriptions are updated.
159+
--mine Update PR descriptions for all PRs opened by the current user associated with the GitHub token.
160+
161+
--related Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch.
162+
If ``machete.github.prDescriptionIntroStyle`` is ``up-only`` (default), then only downstream PR descriptions are updated.
163+
If ``machete.github.prDescriptionIntroStyle`` is ``full``, then both downstream and upstream PR descriptions are updated.
162164

163165
**Git config keys:**
164166

docs/source/cli/gitlab.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,21 @@ Creates, checks out and manages GitLab MRs while keeping them reflected in branc
137137
-U, --update-related-descriptions Update the generated sections ("intros") of MR descriptions that list the upstream and/or downstream MRs.
138138
See help for ``git machete gitlab update-mr-descriptions --related`` for details.
139139

140-
``update-mr-descriptions``:
140+
``update-mr-descriptions [--all | --by=<gitlab-login> | --mine | --related]``:
141141
Updates the generated sections ("intros") of MR descriptions that list the upstream and/or downstream MRs
142142
(depending on ``machete.gitlab.mrDescriptionIntroStyle`` git config key).
143143

144144
**Options:**
145145

146-
--all Update MR descriptions for all MRs in the project.
146+
--all Update MR descriptions for all MRs in the project.
147147

148-
--mine Update MR descriptions for all MRs opened by the current user associated with the GitLab token.
148+
--by=<gitlab-login> Update MR descriptions for all MRs authored by the given GitLab user, where ``<gitlab-login>`` is the GitLab account name.
149149

150-
--related Update MR descriptions for all MRs that are upstream and/or downstream of the MR for the current branch.
151-
If ``machete.gitlab.mrDescriptionIntroStyle`` is ``up-only`` (default), then only downstream MR descriptions are updated.
152-
If ``machete.gitlab.mrDescriptionIntroStyle`` is ``full``, then both downstream and upstream MR descriptions are updated.
150+
--mine Update MR descriptions for all MRs opened by the current user associated with the GitLab token.
151+
152+
--related Update MR descriptions for all MRs that are upstream and/or downstream of the MR for the current branch.
153+
If ``machete.gitlab.mrDescriptionIntroStyle`` is ``up-only`` (default), then only downstream MR descriptions are updated.
154+
If ``machete.gitlab.mrDescriptionIntroStyle`` is ``full``, then both downstream and upstream MR descriptions are updated.
153155

154156
**Git config keys:**
155157

0 commit comments

Comments
 (0)