Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
two space not four
also when wrapping cd in subshell, start subshell on same line
  • Loading branch information
joelmccracken committed Dec 27, 2024
1 parent 1a11642 commit de8c4c7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 40 deletions.
13 changes: 4 additions & 9 deletions ws_tool/lib/properties.bash
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ prop_ws_check_workstation_dir_fix() {
# somehow figure out another way to do this?
TMPINST="$(mktemp -d "${TMPDIR:-/tmp}/ws-install-XXXXXXXXX")"
# installer of ws tool/project
(
cd "$TMPINST";
( cd "$TMPINST";
curl -L https://github.com/joelmccracken/workstation/archive/${WORKSTATION_VERSION}.tar.gz | tar zx;

mkdir -p "$WORKSTATION_DIR";
Expand All @@ -166,8 +165,7 @@ prop_ws_check_workstation_repo() {
}

prop_ws_check_workstation_repo_fix() {
(
cd "$WORKSTATION_DIR";
( cd "$WORKSTATION_DIR";
git init .;
git remote add origin "$WORKSTATION_REPO_GIT_ORIGIN";
git fetch;
Expand All @@ -188,8 +186,7 @@ prop_ws_dotfiles_git_track() {

prop_ws_dotfiles_git_track_fix() {
export GIT_DIR="$WORKSTATION_DOTFILES_TRACK_GIT_DIR"
(
cd "$HOME";
( cd "$HOME";
git init
)
return 0
Expand Down Expand Up @@ -223,9 +220,7 @@ prop_ws_config_exists_fix() {

# hack, because if a relative dir is used for $workstation_initial_config_dir_arg
# we want it to go back...
(
cd "$ws_initial_pwd";
cd "$src_dir";
( cd "$ws_initial_pwd"; cd "$src_dir";
# not perfect, but not worth making much more complicated
for f in *; do
if [[ -e "$WORKSTATION_CONFIG_DIR/$f" ]]; then
Expand Down
8 changes: 4 additions & 4 deletions ws_tool/test/bootstrap_doctor.bats
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

setup (){
load 'test_helper/helper'
_setup_common
. "$PROJECT_ROOT/ws_tool/lib/properties.bash"
. "$PROJECT_ROOT/ws_tool/lib/bootstrap_doctor.bash"
load 'test_helper/helper'
_setup_common
. "$PROJECT_ROOT/ws_tool/lib/properties.bash"
. "$PROJECT_ROOT/ws_tool/lib/bootstrap_doctor.bash"
}

@test "ensure props handles additional props correctly" {
Expand Down
3 changes: 0 additions & 3 deletions ws_tool/test/installation_process.bats
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ EOF
export WORKSTATION_DIR="${WORKSTATION_CONFIG_DIR}/workstation_source"
export WORKSTATION_VERSION=workcomp

(
cd "$(_mktemp "ws-installer-dl-dir")"
do_ws_install() {
bash <(curl "https://raw.githubusercontent.com/joelmccracken/workstation/refs/heads/${WORKSTATION_VERSION}/ws_tool/ws_install.sh")
}
Expand All @@ -66,5 +64,4 @@ EOF
run "${WORKSTATION_DIR}/ws_tool/ws" bootstrap

assert_success
)
}
11 changes: 5 additions & 6 deletions ws_tool/test/properties.bats
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,11 @@ setup (){
run prop_ws_config_exists
assert_success

(
cd "$workstation_initial_config_dir_arg"
for f in *; do
# utter insanity
assert [ "$(cat $f)" == "$(cat "$WORKSTATION_CONFIG_DIR/$f")" ]
done
( cd "$workstation_initial_config_dir_arg";
for f in *; do
# utter insanity
assert [ "$(cat $f)" == "$(cat "$WORKSTATION_CONFIG_DIR/$f")" ]
done
)
}

Expand Down
25 changes: 12 additions & 13 deletions ws_tool/test/test_helper/helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@ set_workstation_version_last_sha() {
}

retfunc() {
# use set -o posix
# plus saving and restoring sets
# to make set print vars (and not functions)
local orig_sets
orig_sets=$(set +o)
set -o posix
"$@";

set | while read -r i; do
printf "VAR:%s" "$i";
done
# declare -p REPLY
eval "$orig_sets"
# use set -o posix
# plus saving and restoring sets
# to make set print vars (and not functions)
local orig_sets
orig_sets=$(set +o)
set -o posix
"$@";
set | while read -r i; do
printf "VAR:%s" "$i";
done
# declare -p REPLY
eval "$orig_sets"
}

dump_output() {
Expand Down
9 changes: 4 additions & 5 deletions ws_tool/ws_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

TMPINST=$(mktemp -d "${TMPDIR:-/tmp}/ws-install.XXXXXXXXX")
# installer of ws tool/project
(
cd "$TMPINST"
curl -L https://github.com/joelmccracken/workstation/archive/${WORKSTATION_VERSION}.tar.gz | tar zx
( cd "$TMPINST";
curl -L https://github.com/joelmccracken/workstation/archive/${WORKSTATION_VERSION}.tar.gz | tar zx

mkdir -p "$WORKSTATION_DIR"
mv "${TMPINST}"/workstation-*/{,.[^.]}* "$WORKSTATION_DIR"
mkdir -p "$WORKSTATION_DIR"
mv "${TMPINST}"/workstation-*/{,.[^.]}* "$WORKSTATION_DIR"
)

0 comments on commit de8c4c7

Please sign in to comment.