Skip to content

Commit

Permalink
Merge pull request #106 from nhomble/gh-105
Browse files Browse the repository at this point in the history
relink on upgrade
  • Loading branch information
juanibiapina authored Mar 27, 2022
2 parents d53eb7b + 44ebd96 commit 503d739
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 6 deletions.
7 changes: 7 additions & 0 deletions libexec/basher-_link
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

package="$1"

basher-_link-bins "$package"
basher-_link-completions "$package"
basher-_link-man "$package"
7 changes: 7 additions & 0 deletions libexec/basher-_unlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

package="$1"

basher-_unlink-man "$package"
basher-_unlink-bins "$package"
basher-_unlink-completions "$package"
4 changes: 1 addition & 3 deletions libexec/basher-install
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,4 @@ else
basher-_clone "$use_ssh" "$site" "$package" "$ref"
fi
basher-_deps "$package"
basher-_link-bins "$package"
basher-_link-man "$package"
basher-_link-completions "$package"
basher-_link "$package"
4 changes: 1 addition & 3 deletions libexec/basher-uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ if [ ! -d "$BASHER_PACKAGES_PATH/$package" ]; then
exit 1
fi

basher-_unlink-man "$package"
basher-_unlink-bins "$package"
basher-_unlink-completions "$package"
basher-_unlink "$package"

rm -rf "${BASHER_PACKAGES_PATH}/$package"
3 changes: 3 additions & 0 deletions libexec/basher-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ if [ -z "$name" ]; then
fi

cd "${BASHER_PACKAGES_PATH}/$package"

basher-_unlink "$package"
git pull
basher-_link "$package"
38 changes: 38 additions & 0 deletions tests/basher-upgrade.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,41 @@ load test_helper
run basher-outdated
assert_output ""
}

@test "upgrade includes man page changes" {
mock_clone
create_package username/package
basher-install username/package
create_man username/package exec.1

assert [ ! -d "$BASHER_INSTALL_MAN" ]
basher-upgrade username/package


run basher-outdated
assert_output ""

assert [ -d "$BASHER_INSTALL_MAN" ]
assert [ -e "$BASHER_INSTALL_MAN/man1/exec.1" ]
}

@test "upgrade removes old binaries" {
mock_clone
create_package username/package
basher-install username/package
create_exec username/package "second"

basher-upgrade username/package

run basher-outdated
assert_output ""

assert [ -e "${BASHER_INSTALL_BIN}/second" ]

remove_exec username/package "second"
run basher-outdated
assert_output "username/package"
basher-upgrade username/package

assert [ ! -e "${BASHER_INSTALL_BIN}/second" ]
}
10 changes: 10 additions & 0 deletions tests/lib/package_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,22 @@ create_exec() {
cd "${BASHER_ORIGIN_DIR}/$package"
mkdir -p bin
touch bin/$exec
chmod +x bin/$exec

git add .
git commit -m "Add $exec"
cd ${BASHER_CWD}
}

remove_exec() {
local package="$1"
local exec="$2"
cd "${BASHER_ORIGIN_DIR}/$package"
git rm bin/$exec
git commit -a -m "Remove $exec"
cd ${BASHER_CWD}
}

create_root_exec() {
local package="$1"
local exec="$2"
Expand Down

0 comments on commit 503d739

Please sign in to comment.