Skip to content

Commit 361e2d9

Browse files
committed
- Update clone command --shallow and --default
1 parent 311e305 commit 361e2d9

23 files changed

+147
-97
lines changed

rush

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ rush_usage() {
5959

6060
# :environment_variable.usage
6161
echo " RUSH_CONFIG"
62-
printf " Location of the rush config file\n Default: ~/rush.ini\n"
62+
printf " Location of the rush config file.\n Default: ~/rush.ini\n"
6363
echo
6464

6565
fi
@@ -97,12 +97,12 @@ rush_add_usage() {
9797

9898
# :argument.usage
9999
echo " REPO"
100-
printf " Repository name\n"
100+
printf " Repository name.\n"
101101
echo
102102

103103
# :argument.usage
104104
echo " PATH"
105-
printf " Path to the repository\n"
105+
printf " Path to the repository.\n"
106106
echo
107107

108108
# :command.usage_examples
@@ -143,14 +143,14 @@ rush_remove_usage() {
143143
# :command.usage_flags
144144
# :flag.usage
145145
echo " --purge, -p"
146-
printf " Also remove the local repository's directory\n"
146+
printf " Also remove the local repository's directory.\n"
147147
echo
148148
# :command.usage_args
149149
printf "Arguments:\n"
150150

151151
# :argument.usage
152152
echo " REPO"
153-
printf " Repository name\n"
153+
printf " Repository name.\n"
154154
echo
155155

156156
# :command.usage_examples
@@ -189,17 +189,22 @@ rush_clone_usage() {
189189
# :command.usage_flags
190190
# :flag.usage
191191
echo " --ssh, -s"
192-
printf " Clone using SSH instead of HTTPS\n"
192+
printf " Clone using SSH instead of HTTPS.\n"
193+
echo
194+
195+
# :flag.usage
196+
echo " --default, -d"
197+
printf " Set this as the default repository (same as '--name default').\n"
193198
echo
194199

195200
# :flag.usage
196201
echo " --name, -n NAME"
197-
printf " Name to use in the config file\n Default: GitHub user\n"
202+
printf " Name to use in the config file.\n Default: GitHub user\n"
198203
echo
199204

200205
# :flag.usage
201-
echo " --full, -f"
202-
printf " Perform a full clone, instead of the default shallow clone\n"
206+
echo " --shallow, -w"
207+
printf " Perform a shallow clone, instead of the default full clone.\n"
203208
echo
204209

205210
# :flag.usage
@@ -211,18 +216,19 @@ rush_clone_usage() {
211216

212217
# :argument.usage
213218
echo " GITHUB_USER"
214-
printf " Github user\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
219+
printf " Github user.\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
215220
echo
216221

217222
# :argument.usage
218223
echo " PATH"
219-
printf " Local path to clone the repository to\n Default: ~/rush-repos/<github_user>/<github_repo>\n"
224+
printf " Local path to clone the repository to.\n Default: ~/rush-repos/<github_user>/<github_repo>\n"
220225
echo
221226

222227
# :command.usage_examples
223228
printf "Examples:\n"
224229

225230
printf " rush clone bobby\n"
231+
printf " rush clone bobby --default\n"
226232
printf " rush clone bobby/bobs-repo ./repos/bobby --ssh\n"
227233
printf " rush clone bobby --name sample --ignore\n"
228234
echo
@@ -260,7 +266,7 @@ rush_pull_usage() {
260266

261267
# :argument.usage
262268
echo " REPO"
263-
printf " Repository name\n"
269+
printf " Repository name.\n"
264270
echo
265271

266272
fi
@@ -290,14 +296,14 @@ rush_push_usage() {
290296
# :command.usage_flags
291297
# :flag.usage
292298
echo " --message, -m TEXT"
293-
printf " Commit message\n Default: automatic commit\n"
299+
printf " Commit message.\n Default: automatic commit\n"
294300
echo
295301
# :command.usage_args
296302
printf "Arguments:\n"
297303

298304
# :argument.usage
299305
echo " REPO"
300-
printf " Repository name\n"
306+
printf " Repository name.\n"
301307
echo
302308

303309
fi
@@ -330,7 +336,7 @@ rush_config_usage() {
330336
# :command.usage_flags
331337
# :flag.usage
332338
echo " --edit, -e"
333-
printf " Open the configuration file for editing\n"
339+
printf " Open the configuration file for editing.\n"
334340
echo
335341

336342
fi
@@ -365,7 +371,7 @@ rush_default_usage() {
365371

366372
# :argument.usage
367373
echo " REPO"
368-
printf " Repository name\n"
374+
printf " Repository name.\n"
369375
echo
370376

371377
# :command.usage_examples
@@ -406,14 +412,14 @@ rush_get_usage() {
406412
# :command.usage_flags
407413
# :flag.usage
408414
echo " --clone, -c"
409-
printf " Clone the repository if it is not found locally\n This flag will look for a GitHub user with the same name as the\n repository, and attempt to clone their rush-repo repository.\n"
415+
printf " Clone the repository if it is not found locally.\n This flag will look for a GitHub user with the same name as the\n repository, and attempt to clone their rush-repo repository.\n"
410416
echo
411417
# :command.usage_args
412418
printf "Arguments:\n"
413419

414420
# :argument.usage
415421
echo " PACKAGE"
416-
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
422+
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
417423
echo
418424

419425
# :command.usage_examples
@@ -459,7 +465,7 @@ rush_undo_usage() {
459465

460466
# :argument.usage
461467
echo " PACKAGE"
462-
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
468+
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
463469
echo
464470

465471
# :command.usage_examples
@@ -501,12 +507,12 @@ rush_snatch_usage() {
501507

502508
# :argument.usage
503509
echo " GITHUB_USER"
504-
printf " Github user\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
510+
printf " Github user.\n This user is expected to have a repository named 'rush-repo'.\n If you need to use a different name, use the 'user/repo' syntax.\n"
505511
echo
506512

507513
# :argument.usage
508514
echo " PACKAGE"
509-
printf " Package name\n"
515+
printf " Package name.\n"
510516
echo
511517

512518
# :command.usage_examples
@@ -551,7 +557,7 @@ rush_info_usage() {
551557

552558
# :argument.usage
553559
echo " PACKAGE"
554-
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
560+
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
555561
echo
556562

557563
# :command.usage_examples
@@ -591,14 +597,14 @@ rush_list_usage() {
591597
# :command.usage_flags
592598
# :flag.usage
593599
echo " --simple, -s"
594-
printf " Show only package names\n"
600+
printf " Show only package names.\n"
595601
echo
596602
# :command.usage_args
597603
printf "Arguments:\n"
598604

599605
# :argument.usage
600606
echo " REPO_OR_PACKAGE"
601-
printf " Repository name or package name\n - Leave blank to show all packages in all repositories.\n - Provide a repository name to show only packages in this repository.\n - Provide a package name (may be in the form of 'repo:package') to\n show nested packages.\n"
607+
printf " Repository name or package name.\n - Leave blank to show all packages in all repositories.\n - Provide a repository name to show only packages in this repository.\n - Provide a package name (may be in the form of 'repo:package') to\n show nested packages.\n"
602608
echo
603609

604610
# :command.usage_examples
@@ -644,7 +650,7 @@ rush_search_usage() {
644650

645651
# :argument.usage
646652
echo " TEXT"
647-
printf " Text to search for\n"
653+
printf " Text to search for.\n"
648654
echo
649655

650656
fi
@@ -680,12 +686,12 @@ rush_edit_usage() {
680686

681687
# :argument.usage
682688
echo " PACKAGE"
683-
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
689+
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
684690
echo
685691

686692
# :argument.usage
687693
echo " FILE"
688-
printf " File to edit\n Default: main\n"
694+
printf " File to edit.\n Default: main\n"
689695
echo
690696

691697
fi
@@ -718,12 +724,12 @@ rush_show_usage() {
718724

719725
# :argument.usage
720726
echo " PACKAGE"
721-
printf " Package name\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
727+
printf " Package name.\n This can either be the package name without the repository name (in\n this case, the default repository will be used) or in the form of\n 'repo:package'.\n"
722728
echo
723729

724730
# :argument.usage
725731
echo " FILE"
726-
printf " File to show (show all if not specified)\n"
732+
printf " File to show (show all if not specified).\n"
727733
echo
728734

729735
fi
@@ -961,10 +967,16 @@ rush_clone_command() {
961967
path=${args[path]}
962968
repo_id=${args[github_user]}
963969
use_ssh=${args[--ssh]}
964-
full=${args[--full]}
970+
shallow=${args[--shallow]}
965971
ignore=${args[--ignore]}
966972
default_repo_name=${repo_id%%/*}
967-
repo_name=${args[--name]:-$default_repo_name}
973+
default=${args[--default]}
974+
975+
if [[ $default ]] ; then
976+
repo_name=default
977+
else
978+
repo_name=${args[--name]:-$default_repo_name}
979+
fi
968980

969981
# Adjust repo_id - defaults to $user/rush-repo
970982
[[ $repo_id = */* ]] || repo_id="$repo_id/rush-repo"
@@ -1004,10 +1016,10 @@ rush_clone_command() {
10041016
# Clone
10051017
say "clone" "$repo_url"
10061018

1007-
if [[ $full ]]; then
1008-
git clone "$repo_url" "$path"
1009-
else
1019+
if [[ $shallow ]]; then
10101020
git clone --depth 1 "$repo_url" "$path"
1021+
else
1022+
git clone "$repo_url" "$path"
10111023
fi
10121024

10131025
# Save config
@@ -1769,6 +1781,12 @@ rush_clone_parse_requirements() {
17691781
shift
17701782
;;
17711783

1784+
# :flag.case
1785+
--default | -d )
1786+
args[--default]=1
1787+
shift
1788+
;;
1789+
17721790
# :flag.case
17731791
--name | -n )
17741792
if [[ $2 ]]; then
@@ -1782,8 +1800,8 @@ rush_clone_parse_requirements() {
17821800
;;
17831801

17841802
# :flag.case
1785-
--full | -f )
1786-
args[--full]=1
1803+
--shallow | -w )
1804+
args[--shallow]=1
17871805
shift
17881806
;;
17891807

0 commit comments

Comments
 (0)