Skip to content

Commit 9719a57

Browse files
committed
fix: Upgrading a package now shows unlinking info messages
1 parent 1d6493a commit 9719a57

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

pkg/lib/commands/do-upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ do_actual_upgrade() {
6161
do-plumbing-unlink-bins "$id"
6262
do-plumbing-unlink-completions "$id"
6363
do-plumbing-unlink-man "$id"
64-
local git_output=
6564

65+
local git_output=
6666
if ! git_output="$(git -C "$BPM_PACKAGES_PATH/$id" pull 2>&1)"; then
6767
log.error "Could not update Git repository"
6868
printf "%s\n" "$git_output"

pkg/lib/util/abstract-bins.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# shellcheck shell=bash
22

3-
abstract_bins_did=no
4-
53
abstract.bins() {
64
local action="$1"
75
local id="$2"
86
ensure.non_zero 'action' "$action"
97
ensure.non_zero 'id' "$id"
108

9+
abstract_bins_did=no
10+
1111
local -a bins=()
1212
local remove_extensions=
1313

pkg/lib/util/abstract-completions.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# shellcheck shell=bash
22

3-
abstract_completions_did=no
4-
53
abstract.completions() {
64
local action="$1"
75
local id="$2"
86
ensure.non_zero 'action' "$action"
97
ensure.non_zero 'id' "$id"
108
ensure.package_exists "$id"
119

10+
abstract_completions_did=no
11+
1212
local bpm_toml_file="$BPM_PACKAGES_PATH/$id/bpm.toml"
1313
local package_sh_file="$BPM_PACKAGES_PATH/$id/package.sh"
1414

@@ -155,7 +155,7 @@ abstract.completions_do_action_zsh() {
155155
local file="$2"
156156

157157
abstract.completions_do_echo
158-
158+
159159
if grep -qs "^#compdef" "$file"; then
160160
local fileName="${file##*/}"
161161
if [ "${fileName::1}" != _ ]; then

pkg/lib/util/abstract-mans.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# shellcheck shell=bash
22

3-
abstract_mans_did=no
43

54
abstract.mans() {
65
local action="$1"
@@ -9,6 +8,8 @@ abstract.mans() {
98
ensure.non_zero 'id' "$id"
109
ensure.package_exists "$id"
1110

11+
abstract_mans_did=no
12+
1213
local bpm_toml_file="$BPM_PACKAGES_PATH/$id/bpm.toml"
1314

1415
if [ -f "$bpm_toml_file" ]; then

tests/do-upgrade.bats

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,33 @@ load 'util/init.sh'
4848
assert_line -p "Package '$BPM_ORIGIN_DIR/$pkg' is not installed"
4949
}
5050

51+
@test "simple upgrade properly prints linking and unlinking messages" {
52+
local site='github.com'
53+
local pkg='somedir/package'
54+
55+
test_util.create_package "$pkg"
56+
test_util.mock_clone "$pkg" "$site/$pkg"
57+
58+
cd "$BPM_ORIGIN_DIR/$pkg"
59+
mkdir 'completions' 'bin' 'man' 'man/man1'
60+
touch 'completions/file.sh' 'bin/file' 'man/man1/file.1'
61+
git add .
62+
git commit -m 'Add script'
63+
cd "$BPM_CWD"
64+
65+
do-upgrade "$site/$pkg"
66+
67+
unset BPM_MODE_TEST
68+
run do-upgrade "$pkg"
69+
70+
assert_success
71+
assert_line -p -n 1 "Unlinking bin files"
72+
assert_line -p -n 2 "Unlinking completion files"
73+
assert_line -p -n 3 "Unlinking man files"
74+
assert_line -p -n 4 "Linking bin files"
75+
assert_line -p -n 5 "Linking completion files"
76+
assert_line -p -n 6 "Linking man files"
77+
}
5178

5279
@test "symlinks stay valid after upgrade" {
5380
local site='github.com'

0 commit comments

Comments
 (0)