Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ first. It will never:
pullr [options] [DIR]
```

Short options can be combined: `-rs` is `-r -s`, and `-j8` or `-rj 8` set
the number of jobs.

| Option                       | Default | Meaning |
| :--- | :--- | :--- |
| `DIR` | current directory | Where to look for repositories |
Expand Down
12 changes: 12 additions & 0 deletions bin/pullr
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Options:
set (https://no-color.org) or output is not a terminal.
-V, --version Print the version.
-h, --help Show this help.

Short options can be combined: -rs is -r -s, and -j8 or -rj 8 set the jobs.
EOF
}

Expand All @@ -50,6 +52,16 @@ root=""

while (($#)); do
case "$1" in
# bundled short options: split -rs into -r -s, and -j8 into -j 8
-[!-]?*)
opt="${1:1:1}" rest="${1:2}"
shift
if [[ "$opt" == j ]]; then
set -- -j "$rest" "$@"
else
set -- "-$opt" "-$rest" "$@"
fi
;;
-j|--jobs) jobs="${2:-}"; shift 2 || { usage >&2; exit 2; } ;;
--jobs=*) jobs="${1#*=}"; shift ;;
--max-depth) max_depth="${2:-}"; shift 2 || { usage >&2; exit 2; } ;;
Expand Down
25 changes: 25 additions & 0 deletions test/pullr.bats
Original file line number Diff line number Diff line change
Expand Up @@ -587,3 +587,28 @@ make_edited() {
[ "$status" -eq 0 ]
[[ "$output" == *" + app/lib (main, 1 new commit)"* ]]
}

@test "short options combine: -sn, -j8, -snj 1 and -rs" {
make_app_with_submodule
git -C ws/app/lib commit -q --allow-empty -m "my lib work"
advance_lib 2
run pullr -sn ws
[[ "$output" == "Dry run: nothing will be pulled."* ]]
[[ "$output" == *" x app/lib (main)"* ]]
run pullr -j8 -n ws
[ "$status" -eq 0 ]
run pullr -snj 1 ws
[[ "$output" == *" x app/lib (main)"* ]]
run pullr -rs ws
[ "$status" -eq 0 ]
[[ "$output" == *" + app/lib (main, 1 new commit, 1 rebased)"* ]]
[ "$(git -C ws/app/lib log -1 --format=%s)" = "my lib work" ]
}

@test "an unknown letter in a bundle is rejected" {
run pullr -rx ws
[ "$status" -eq 2 ]
[[ "$output" == *"Unknown option: -x"* ]]
run pullr -rj
[ "$status" -eq 2 ]
}
Loading