Skip to content

Commit f1b8e76

Browse files
committed
feat: Error if ref is given when uninstalling or upgrading package
Ref is not required since there can only be one version of any particular package at any point in time. This reduces confusion due to the extraneous disambiguation
1 parent 9719a57 commit f1b8e76

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

pkg/lib/commands/do-remove.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ do-remove() {
4848
util.extract_data_from_input "$repoSpec"
4949
local site="$REPLY2"
5050
local package="$REPLY3"
51+
local ref="$REPLY4"
52+
53+
if [ -n "$ref" ]; then
54+
die "Refs must be omitted when upgrading packages. Remove ref '@$ref'"
55+
fi
5156

5257
if [ -d "$BPM_PACKAGES_PATH/$site/$package" ]; then
5358
do_actual_removal "$site/$package"

pkg/lib/commands/do-upgrade.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ do-upgrade() {
4242
util.extract_data_from_input "$repoSpec"
4343
local site="$REPLY2"
4444
local package="$REPLY3"
45+
local ref="$REPLY4"
46+
47+
if [ -n "$ref" ]; then
48+
die "Refs must be omitted when upgrading packages. Remove ref '@$ref'"
49+
fi
4550

4651
if [ -L "$BPM_PACKAGES_PATH/$site/$package" ]; then
4752
die "Package '$site/$package' is locally symlinked and cannot be upgraded through Git"

tests/do-remove.bats

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,17 @@ load 'util/init.sh'
182182
assert_failure
183183
assert_line -p "No packages may be supplied when using '--all'"
184184
}
185+
186+
187+
@test "fail if ref is given during remove" {
188+
local site='github.com'
189+
local pkg='username/package'
190+
191+
test_util.create_package "$pkg"
192+
test_util.mock_clone "$pkg" "$site/$pkg"
193+
194+
run do-upgrade "$pkg@v0.1.0"
195+
196+
assert_failure
197+
assert_line -p "Refs must be omitted when upgrading packages. Remove ref '@v0.1.0'"
198+
}

tests/do-upgrade.bats

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,16 @@ load 'util/init.sh'
168168
assert_failure
169169
assert_line -p 'Packages cannot be upgraded at the same time as bpm'
170170
}
171+
172+
@test "fail if ref is given during upgrade" {
173+
local site='github.com'
174+
local pkg='username/package'
175+
176+
test_util.create_package "$pkg"
177+
test_util.mock_clone "$pkg" "$site/$pkg"
178+
179+
run do-upgrade "$pkg@v0.1.0"
180+
181+
assert_failure
182+
assert_line -p "Refs must be omitted when upgrading packages. Remove ref '@v0.1.0'"
183+
}

0 commit comments

Comments
 (0)