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 26, 2024
1 parent a6d490d commit ca148af
Show file tree
Hide file tree
Showing 13 changed files with 388 additions and 143 deletions.
4 changes: 3 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release notes

## New in git-machete 3.30.1
## New in git-machete 3.31.0

- added: `git machete git{hub,lab} update-{pr,mr}-descriptions` subcommands

## New in git-machete 3.30.0

Expand Down
57 changes: 31 additions & 26 deletions completion/git-machete.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ _git_machete() {

local categories="addable childless managed slidable slidable-after unmanaged with-overridden-fork-point"
local directions="down first last next prev root up"
local github_subcommands="anno-prs checkout-prs create-pr restack-pr retarget-pr"
local gitlab_subcommands="anno-mrs checkout-mrs create-mr restack-mr retarget-mr"
local github_subcommands="anno-prs checkout-prs create-pr restack-pr retarget-pr update-pr-descriptions"
local gitlab_subcommands="anno-mrs checkout-mrs create-mr restack-mr retarget-mr update-mr-descriptions"
local locations="current $directions"
local opt_color_args="always auto never"
local opt_return_to_args="here nearest-remaining stay"
Expand All @@ -22,14 +22,11 @@ _git_machete() {
local diff_opts="-s --stat"
local discover_opts="-C --checked-out-since= -l --list-commits -r --roots= -y --yes"
local fork_point_opts="--inferred --override-to= --override-to-inferred --override-to-parent --unset-override"
local github_anno_prs_opts="--with-urls"
local github_create_pr_opts="--draft --title= --yes"
local github_checkout_prs_opts="--all --by= --mine"
local github_retarget_pr_opts="-b --branch= --ignore-if-missing"
local gitlab_anno_mrs_opts="--with-urls"
local gitlab_create_mr_opts="--draft --title= --yes"
local gitlab_checkout_mrs_opts="--all --by= --mine"
local gitlab_retarget_mr_opts="-b --branch= --ignore-if-missing"
local githublab_anno_opts="--with-urls"
local githublab_create_opts="--draft --title= --yes"
local githublab_checkout_opts="--all --by= --mine"
local githublab_retarget_opts="-b --branch= --ignore-if-missing"
local githublab_update_descriptions_opts="--all --mine --related"
local reapply_opts="-f --fork-point="
local slide_out_opts="-d --down-fork-point= --delete -M --merge -n --no-edit-merge --no-interactive-rebase --removed-from-remote"
local squash_opts="-f --fork-point="
Expand Down Expand Up @@ -57,25 +54,29 @@ _git_machete() {
fork-point) __gitcomp "$common_opts $fork_point_opts" ;;
github)
if [[ ${COMP_WORDS[3]} == "anno-prs" ]]; then
__gitcomp "$common_opts $github_anno_prs_opts"
__gitcomp "$common_opts $githublab_anno_opts"
elif [[ ${COMP_WORDS[3]} == "create-pr" ]]; then
__gitcomp "$common_opts $github_create_pr_opts"
__gitcomp "$common_opts $githublab_create_opts"
elif [[ ${COMP_WORDS[3]} == "checkout-prs" ]]; then
__gitcomp "$common_opts $github_checkout_prs_opts"
__gitcomp "$common_opts $githublab_checkout_opts"
elif [[ ${COMP_WORDS[3]} == "retarget-pr" ]]; then
__gitcomp "$common_opts $github_retarget_pr_opts"
__gitcomp "$common_opts $githublab_retarget_opts"
elif [[ ${COMP_WORDS[3]} == "update-pr-descriptions" ]]; then
__gitcomp "$common_opts $githublab_update_descriptions_opts"
else
__gitcomp "$common_opts"
fi ;;
gitlab)
if [[ ${COMP_WORDS[3]} == "anno-mrs" ]]; then
__gitcomp "$common_opts $gitlab_anno_mrs_opts"
__gitcomp "$common_opts $githublab_anno_opts"
elif [[ ${COMP_WORDS[3]} == "create-mr" ]]; then
__gitcomp "$common_opts $gitlab_create_mr_opts"
__gitcomp "$common_opts $githublab_create_opts"
elif [[ ${COMP_WORDS[3]} == "checkout-mrs" ]]; then
__gitcomp "$common_opts $gitlab_checkout_mrs_opts"
__gitcomp "$common_opts $githublab_checkout_opts"
elif [[ ${COMP_WORDS[3]} == "retarget-mr" ]]; then
__gitcomp "$common_opts $gitlab_retarget_mr_opts"
__gitcomp "$common_opts $githublab_retarget_opts"
elif [[ ${COMP_WORDS[3]} == "update-mr-descriptions" ]]; then
__gitcomp "$common_opts $githublab_update_descriptions_opts"
else
__gitcomp "$common_opts"
fi ;;
Expand Down Expand Up @@ -133,27 +134,31 @@ _git_machete() {
if [[ $COMP_CWORD -eq 3 ]]; then
__gitcomp "$github_subcommands"
elif [[ ${COMP_WORDS[3]} == "anno-prs" ]]; then
__gitcomp "$common_opts $github_anno_prs_opts"
__gitcomp "$common_opts $githublab_anno_opts"
elif [[ ${COMP_WORDS[3]} == "create-pr" ]]; then
__gitcomp "$common_opts $github_create_pr_opts"
__gitcomp "$common_opts $githublab_create_opts"
elif [[ ${COMP_WORDS[3]} == "checkout-prs" ]]; then
__gitcomp "$common_opts $github_checkout_prs_opts"
__gitcomp "$common_opts $githublab_checkout_opts"
elif [[ ${COMP_WORDS[3]} == "retarget-pr" ]]; then
__gitcomp "$common_opts $github_retarget_pr_opts"
__gitcomp "$common_opts $githublab_retarget_opts"
elif [[ ${COMP_WORDS[3]} == "update-pr-descriptions" ]]; then
__gitcomp "$common_opts $githublab_update_descriptions_opts"
else
COMPREPLY=('')
fi ;;
gitlab)
if [[ $COMP_CWORD -eq 3 ]]; then
__gitcomp "$gitlab_subcommands"
elif [[ ${COMP_WORDS[3]} == "anno-mrs" ]]; then
__gitcomp "$common_opts $gitlab_anno_mrs_opts"
__gitcomp "$common_opts $githublab_anno_opts"
elif [[ ${COMP_WORDS[3]} == "create-mr" ]]; then
__gitcomp "$common_opts $gitlab_create_mr_opts"
__gitcomp "$common_opts $githublab_create_opts"
elif [[ ${COMP_WORDS[3]} == "checkout-mrs" ]]; then
__gitcomp "$common_opts $gitlab_checkout_mrs_opts"
__gitcomp "$common_opts $githublab_checkout_opts"
elif [[ ${COMP_WORDS[3]} == "retarget-mr" ]]; then
__gitcomp "$common_opts $gitlab_retarget_mr_opts"
__gitcomp "$common_opts $githublab_retarget_opts"
elif [[ ${COMP_WORDS[3]} == "update-mr-descriptions" ]]; then
__gitcomp "$common_opts $githublab_update_descriptions_opts"
else
COMPREPLY=('')
fi ;;
Expand Down
18 changes: 18 additions & 0 deletions completion/git-machete.completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ __git_machete_github_subcommands() {
'create-pr:create a PR for the current branch, using the upstream (parent) branch as the PR base'
'restack-pr:(force-)push and retarget the PR, without adding code owners as reviewers in the process'
'retarget-pr:set the base of the current branch PR to upstream (parent) branch'
'update-pr-descriptions:update the generated sections of PR descriptions that lists the upstream and/or downstream PRs'
)
_describe 'subcommand' github_subcommands
;;
Expand Down Expand Up @@ -289,6 +290,14 @@ __git_machete_github_subcommands() {
'(--ignore-if-missing)'--ignore-if-missing'[Ignore errors and quietly terminate execution if there is no PR opened for current (or specified) branch]' \
"${common_flags[@]}"
;;

(update-pr-descriptions)
_arguments \
'(--all)'--all'[Update PR descriptions for all PRs in the repository]' \
'(--mine)'--mine='[Update PR descriptions for all PRs opened by the current user associated with the GitHub token]' \
'(--related)'--related='[Update PR descriptions for all PRs that are upstream and/or downstream of the PR for the current branch]' \
"${common_flags[@]}"
;;
esac
;;
esac
Expand All @@ -312,6 +321,7 @@ __git_machete_gitlab_subcommands() {
'create-mr:create a MR for the current branch, using the upstream (parent) branch as the MR source branch'
'restack-mr:(force-)push and retarget the MR, without adding code owners as reviewers in the process'
'retarget-mr:set the source branch of the current branch MR to upstream (parent) branch'
'update-mr-descriptions:update the generated sections of MR descriptions that list the upstream and/or downstream MRs'
)
_describe 'subcommand' gitlab_subcommands
;;
Expand Down Expand Up @@ -347,6 +357,14 @@ __git_machete_gitlab_subcommands() {
'(--ignore-if-missing)'--ignore-if-missing'[Ignore errors and quietly terminate execution if there is no MR opened for current (or specified) branch]' \
"${common_flags[@]}"
;;

(update-mr-descriptions)
_arguments \
'(--all)'--all'[Update MR descriptions for all MRs in the project]' \
'(--mine)'--mine='[Update MR descriptions for all MRs opened by the current user associated with the GitLab token]' \
'(--related)'--related='[Update MR descriptions for all MRs that are upstream and/or downstream of the MR for the current branch]' \
"${common_flags[@]}"
;;
esac
;;
esac
Expand Down
Loading

0 comments on commit ca148af

Please sign in to comment.