Skip to content

Commit 5368d32

Browse files
committed
fix: address CI failures and review feedback
- Add apt-get update before installs in CI workflow - Suppress SC2317 on nested adapter functions in bin/gtr - Replace SC2015 pattern with if-statement in lib/copy.sh - Pre-compute AppleScript cmd line to avoid set -e abort in heredoc - Add git identity config in test setup for CI environments - Fix misleading test description for special char replacement
1 parent 06c2301 commit 5368d32

6 files changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v4
1515

1616
- name: Install ShellCheck
17-
run: sudo apt-get install -y shellcheck
17+
run: sudo apt-get update && sudo apt-get install -y shellcheck
1818

1919
- name: Run ShellCheck
2020
run: |
@@ -27,7 +27,7 @@ jobs:
2727
- uses: actions/checkout@v4
2828

2929
- name: Install BATS
30-
run: sudo apt-get install -y bats
30+
run: sudo apt-get update && sudo apt-get install -y bats
3131

3232
- name: Run tests
3333
run: bats tests/

bin/gtr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ ai_start() {
6969
# Standard AI adapter builder — used by adapter files that follow the common pattern
7070
# Sets globals then call this: _AI_CMD, _AI_ERR_MSG, _AI_INFO_LINES (array)
7171
_ai_define_standard() {
72+
# shellcheck disable=SC2317 # Functions are called indirectly via adapter dispatch
7273
ai_can_start() {
7374
command -v "$_AI_CMD" >/dev/null 2>&1
7475
}
7576

77+
# shellcheck disable=SC2317
7678
ai_start() {
7779
local path="$1"; shift
7880
if ! ai_can_start; then
@@ -94,10 +96,12 @@ _ai_define_standard() {
9496
# Standard editor adapter builder — used by adapter files that follow the common pattern
9597
# Sets globals then call this: _EDITOR_CMD, _EDITOR_ERR_MSG, _EDITOR_WORKSPACE (optional, 0 or 1)
9698
_editor_define_standard() {
99+
# shellcheck disable=SC2317 # Functions are called indirectly via adapter dispatch
97100
editor_can_open() {
98101
command -v "$_EDITOR_CMD" >/dev/null 2>&1
99102
}
100103

104+
# shellcheck disable=SC2317
101105
editor_open() {
102106
local path="$1"
103107
local workspace="${2:-}"
@@ -116,10 +120,12 @@ _editor_define_standard() {
116120
# Terminal editor adapter builder — for editors that run in the current terminal
117121
# Sets globals then call this: _EDITOR_CMD, _EDITOR_ERR_MSG, _EDITOR_BACKGROUND (optional, 0 or 1)
118122
_editor_define_terminal() {
123+
# shellcheck disable=SC2317 # Functions are called indirectly via adapter dispatch
119124
editor_can_open() {
120125
command -v "$_EDITOR_CMD" >/dev/null 2>&1
121126
}
122127

128+
# shellcheck disable=SC2317
123129
editor_open() {
124130
local path="$1"
125131
if ! editor_can_open; then

lib/copy.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ copy_directories() {
299299
cd "$exclude_old_pwd" || true
300300

301301
# Log only if we actually removed something
302-
[ "$removed_any" -eq 1 ] && log_info "Excluded subdirectory $exclude_pattern" || true
302+
if [ "$removed_any" -eq 1 ]; then
303+
log_info "Excluded subdirectory $exclude_pattern"
304+
fi
303305
;;
304306
esac
305307
;;

lib/platform.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ spawn_terminal_in() {
9696
safe_title=$(_escape_applescript "$title")
9797
safe_cmd=$(_escape_applescript "$cmd")
9898

99+
# Pre-compute optional AppleScript write-text line (avoids set -e abort in heredoc)
100+
local iterm_cmd_line=""
101+
if [ -n "$safe_cmd" ]; then
102+
iterm_cmd_line="write text \"$safe_cmd\""
103+
fi
104+
99105
# Try iTerm2 first, then Terminal.app
100106
if osascript -e 'tell application "System Events" to get name of first application process whose frontmost is true' 2>/dev/null | grep -q "iTerm"; then
101107
osascript <<-EOF 2>/dev/null || true
@@ -105,7 +111,7 @@ spawn_terminal_in() {
105111
tell current session
106112
write text "cd \"$safe_path\""
107113
set name to "$safe_title"
108-
$([ -n "$safe_cmd" ] && echo "write text \"$safe_cmd\"")
114+
$iterm_cmd_line
109115
end tell
110116
end tell
111117
end tell

tests/resolve_base_dir.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ setup() {
77
# Create a temporary git repo for testing
88
TEST_REPO=$(mktemp -d)
99
git -C "$TEST_REPO" init --quiet
10+
git -C "$TEST_REPO" config user.name "Test User"
11+
git -C "$TEST_REPO" config user.email "test@example.com"
1012
git -C "$TEST_REPO" commit --allow-empty -m "init" --quiet
1113
}
1214

tests/sanitize_branch_name.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ setup() {
4040
[ "$result" = "trailing-slash" ]
4141
}
4242

43-
@test "multiple special chars produce single hyphens" {
43+
@test "multiple special chars are each replaced" {
4444
result=$(sanitize_branch_name "a//b")
4545
[ "$result" = "a--b" ]
4646
}

0 commit comments

Comments
 (0)