Skip to content

Commit d138079

Browse files
koct9ijpgrayson
authored andcommitted
feat(bash): complete patches from chosen branch
stg show -b branch <tab> stg pick -B branch <tab>
1 parent 2eba3c4 commit d138079

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/cmd/completion/bash.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ fn write_command_func(script: &mut ShStream, fname: &str, command: &clap::Comman
6060
&f!("local long_flags=\"{long_flags}\""),
6161
&f!("local options=\"{options_pattern}\""),
6262
"local pos_index=0",
63+
"local __branch",
6364
]);
6465

6566
if !subcommand_names.as_ref().is_empty() {
@@ -83,6 +84,17 @@ fn write_command_func(script: &mut ShStream, fname: &str, command: &clap::Comman
8384
script.lines(&["cmd_index=$i", &f!("{fname}-{subcommand_name}; return;;")]);
8485
script.dedent();
8586
}
87+
script.lines(&[
88+
"-b|--branch|-B|--ref-branch)",
89+
" if (( i < cword )); then",
90+
" __branch=\"${words[i+1]}\"",
91+
" fi",
92+
" ;;",
93+
"--branch=*|--ref-branch=*)",
94+
" __branch=\"${words[i]}\"",
95+
" __branch=\"${__branch#*=}\"",
96+
" ;;",
97+
]);
8698
if !flags_pattern.as_ref().is_empty() {
8799
script.lines(&[&f!("{flags_pattern})"), " ;;"]);
88100
}
@@ -549,29 +561,34 @@ _remotes ()
549561
test "$g" && __git show-ref | grep ' refs/remotes/' | sed 's,.* refs/remotes/,,'
550562
}
551563
564+
_stg_series ()
565+
{
566+
__stg series ${__branch:+"--branch=${__branch}"} "$@"
567+
}
568+
552569
_all_patches ()
553570
{
554-
__stg series --no-description --noprefix --all
571+
_stg_series --no-description --noprefix --all
555572
}
556573
557574
_applied_patches ()
558575
{
559-
__stg series --no-description --noprefix --applied
576+
_stg_series --no-description --noprefix --applied
560577
}
561578
562579
_unapplied_patches ()
563580
{
564-
__stg series --no-description --noprefix --unapplied
581+
_stg_series --no-description --noprefix --unapplied
565582
}
566583
567584
_visible_patches ()
568585
{
569-
__stg series --no-description --noprefix --applied --unapplied
586+
_stg_series --no-description --noprefix --applied --unapplied
570587
}
571588
572589
_hidden_patches ()
573590
{
574-
__stg series --no-description --noprefix --hidden
591+
_stg_series --no-description --noprefix --hidden
575592
}
576593
577594
_conflicting_files ()

0 commit comments

Comments
 (0)