Skip to content

Commit 89d9574

Browse files
committed
- Improve rush list repo/package detection
1 parent b9612ba commit 89d9574

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

rush

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,19 +1101,25 @@ list_show_repo() {
11011101
local simple="$2"
11021102
local all="$3"
11031103
local repo="$repo_or_package"
1104+
local explicit_repo=
11041105
local package glob repo_path infofile regex package_name
11051106

11061107
if [[ $repo_or_package =~ (.*):(.*) ]]; then
1108+
explicit_repo=1
11071109
repo=${BASH_REMATCH[1]}
11081110
package=${BASH_REMATCH[2]}
11091111
fi
11101112

11111113
repo_path=$(config_get "$repo")
11121114

11131115
if [[ ! $repo_path ]]; then
1114-
package="$repo"
1115-
repo="default"
1116-
repo_path=$(config_get "$repo")
1116+
if [[ $explicit_repo ]]; then
1117+
abort "repo not found: $repo"
1118+
else
1119+
package="$repo"
1120+
repo="default"
1121+
repo_path=$(config_get "$repo")
1122+
fi
11171123
fi
11181124

11191125
if [[ $package ]]; then

src/lib/list_show_repo.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@ list_show_repo() {
33
local simple="$2"
44
local all="$3"
55
local repo="$repo_or_package"
6+
local explicit_repo=
67
local package glob repo_path infofile regex package_name
78

89
if [[ $repo_or_package =~ (.*):(.*) ]]; then
10+
explicit_repo=1
911
repo=${BASH_REMATCH[1]}
1012
package=${BASH_REMATCH[2]}
1113
fi
1214

1315
repo_path=$(config_get "$repo")
1416

1517
if [[ ! $repo_path ]]; then
16-
package="$repo"
17-
repo="default"
18-
repo_path=$(config_get "$repo")
18+
if [[ $explicit_repo ]]; then
19+
abort "repo not found: $repo"
20+
else
21+
package="$repo"
22+
repo="default"
23+
repo_path=$(config_get "$repo")
24+
fi
1925
fi
2026

2127
if [[ $package ]]; then
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
repo not found: nope
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nothing in sample repo

test/approve

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ describe "list"
124124
approve "rush list --all"
125125
approve "rush list --all --simple"
126126
approve "rush list hello"
127+
approve "rush list nope:thing" || return 0
128+
expect_exit_code 1
127129
approve "rush list sample"
130+
approve "rush list sample:asd"
128131
approve "rush list nested"
129132
approve "rush list sample:nested"
130133
approve "rush list no-such-package"
@@ -166,4 +169,3 @@ describe "copy"
166169
describe "completions"
167170
approve "rush completions"
168171
approve "rush completions -h"
169-

0 commit comments

Comments
 (0)