Skip to content

Commit 07a3dce

Browse files
committed
- Refactor push command to avoid chmod by default and add --chmod flag
1 parent 9da5e22 commit 07a3dce

File tree

11 files changed

+65
-13
lines changed

11 files changed

+65
-13
lines changed

rush

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ rush_push_usage() {
347347
printf " Default: automatic commit\n"
348348
echo
349349

350+
# :flag.usage
351+
printf " %s\n" "--chmod, -x"
352+
printf " Apply the executable bit to all main and undo scripts in the git repository\n index\n"
353+
echo
354+
350355
# :command.usage_fixed_flags
351356
printf " %s\n" "--help, -h"
352357
printf " Show this help\n"
@@ -1201,7 +1206,7 @@ send_completions() {
12011206
echo $' ;;'
12021207
echo $''
12031208
echo $' \'upload\'*)'
1204-
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --help --message -a -h -m")" -- "$cur" )'
1209+
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --chmod --help --message -a -h -m -x")" -- "$cur" )'
12051210
echo $' ;;'
12061211
echo $''
12071212
echo $' \'config\'*)'
@@ -1225,7 +1230,7 @@ send_completions() {
12251230
echo $' ;;'
12261231
echo $''
12271232
echo $' \'push\'*)'
1228-
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --help --message -a -h -m")" -- "$cur" )'
1233+
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --chmod --help --message -a -h -m -x")" -- "$cur" )'
12291234
echo $' ;;'
12301235
echo $''
12311236
echo $' \'undo\'*)'
@@ -1462,13 +1467,22 @@ rush_push_command() {
14621467
(
14631468
set -e
14641469
cd "$repo_path"
1470+
1471+
say "push" "$repo: adding files"
14651472
git add . --all
1466-
git ls-files | grep -E "undo|main" | xargs -I {} git update-index --chmod +x {}
1473+
1474+
if [[ -n "${args[--chmod]}" ]]; then
1475+
say "push" "$repo: applying chmod +x"
1476+
git ls-files | grep -E "undo|main" | xargs -I {} git update-index --chmod +x {}
1477+
fi
1478+
say "push" "$repo: committing"
14671479
git commit -am "$message"
1480+
1481+
say "push" "$repo: pushing"
14681482
git push
14691483
)
14701484
else
1471-
say "push" "skipping $repo (not a git repo)"
1485+
say "push" "$repo: skipping (not a git repo)"
14721486
fi
14731487
}
14741488

@@ -2438,6 +2452,14 @@ rush_push_parse_requirements() {
24382452
fi
24392453
;;
24402454

2455+
# :flag.case
2456+
--chmod | -x)
2457+
2458+
# :flag.case_no_arg
2459+
args['--chmod']=1
2460+
shift
2461+
;;
2462+
24412463
-?*)
24422464
printf "invalid option: %s\n" "$key" >&2
24432465
exit 1

src/bashly.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ commands:
132132
help: Commit message
133133
default: automatic commit
134134

135+
- long: --chmod
136+
short: -x
137+
help: Apply the executable bit to all main and undo scripts in the git repository index
138+
135139
- name: config
136140
alias: c
137141
group: Config

src/lib/send_completions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ send_completions() {
5151
echo $' ;;'
5252
echo $''
5353
echo $' \'upload\'*)'
54-
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --help --message -a -h -m")" -- "$cur" )'
54+
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --chmod --help --message -a -h -m -x")" -- "$cur" )'
5555
echo $' ;;'
5656
echo $''
5757
echo $' \'config\'*)'
@@ -75,7 +75,7 @@ send_completions() {
7575
echo $' ;;'
7676
echo $''
7777
echo $' \'push\'*)'
78-
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --help --message -a -h -m")" -- "$cur" )'
78+
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --chmod --help --message -a -h -m -x")" -- "$cur" )'
7979
echo $' ;;'
8080
echo $''
8181
echo $' \'undo\'*)'

src/push_command.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@ push_repo() {
1212
(
1313
set -e
1414
cd "$repo_path"
15+
16+
say "push" "$repo: adding files"
1517
git add . --all
16-
git ls-files | grep -E "undo|main" | xargs -I {} git update-index --chmod +x {}
18+
19+
if [[ -n "${args[--chmod]}" ]]; then
20+
say "push" "$repo: applying chmod +x"
21+
git ls-files | grep -E "undo|main" | xargs -I {} git update-index --chmod +x {}
22+
fi
23+
say "push" "$repo: committing"
1724
git commit -am "$message"
25+
26+
say "push" "$repo: pushing"
1827
git push
1928
)
2029
else
21-
say "push" "skipping $repo (not a git repo)"
30+
say "push" "$repo: skipping (not a git repo)"
2231
fi
2332
}
2433

test/approvals/rush_completions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ _rush_completions() {
4949
;;
5050

5151
'upload'*)
52-
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --help --message -a -h -m")" -- "$cur" )
52+
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --chmod --help --message -a -h -m -x")" -- "$cur" )
5353
;;
5454

5555
'config'*)
@@ -73,7 +73,7 @@ _rush_completions() {
7373
;;
7474

7575
'push'*)
76-
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --help --message -a -h -m")" -- "$cur" )
76+
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rush_completions_filter "--all --chmod --help --message -a -h -m -x")" -- "$cur" )
7777
;;
7878

7979
'undo'*)

test/approvals/rush_push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
push | skipping default (not a git repo)
1+
push | default: skipping (not a git repo)

test/approvals/rush_push_all

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
push | skipping default (not a git repo)
2-
push | skipping sample (not a git repo)
1+
push | default: skipping (not a git repo)
2+
push | sample: skipping (not a git repo)
33
push | dannyben
4+
push | dannyben: adding files
5+
push | dannyben: committing
46
On branch master
57
Your branch is up to date with 'origin/master'.
68

test/approvals/rush_push_dannyben

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
push | dannyben
2+
push | dannyben: adding files
3+
push | dannyben: committing
24
On branch master
35
Your branch is up to date with 'origin/master'.
46

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
push | dannyben
2+
push | dannyben: adding files
3+
push | dannyben: applying chmod +x
4+
push | dannyben: committing
5+
On branch master
6+
Your branch is up to date with 'origin/master'.
7+
8+
nothing to commit, working tree clean

test/approvals/rush_push_h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Alias: upload
1414
Commit message
1515
Default: automatic commit
1616

17+
--chmod, -x
18+
Apply the executable bit to all main and undo scripts in the git repository
19+
index
20+
1721
--help, -h
1822
Show this help
1923

0 commit comments

Comments
 (0)