Skip to content

Commit 51f56da

Browse files
Doug Fennellclaude
authored andcommitted
Fix lock path bug and ShellCheck warnings
- Fix acquire_lock path: use "." after cd'ing to deployment_root - Remove unused SCRIPT_DIR and prev_id variables - Separate declare and assign for SCRIPT_NAME and release_id (SC2155) - Use _ for unused loop variable in test-race.sh (SC2034) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1fb60d1 commit 51f56da

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

deploy.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# deploy.sh - Atomic deployment via symlink swap
33
set -euo pipefail
44

5-
readonly SCRIPT_NAME="${0##*/}"
6-
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
SCRIPT_NAME="${0##*/}"
6+
readonly SCRIPT_NAME
77

88
# Global state for cleanup and rollback
99
PREVIOUS_RELEASE=""
@@ -64,9 +64,6 @@ rollback() {
6464
return 0
6565
fi
6666

67-
# Extract release id from path (e.g., "releases/20260112" -> "20260112")
68-
local prev_id="${PREVIOUS_RELEASE##*/}"
69-
7067
if [[ ! -d "$PREVIOUS_RELEASE" ]]; then
7168
error "Previous release directory missing: $PREVIOUS_RELEASE"
7269
return 1
@@ -259,11 +256,13 @@ main() {
259256
mkdir -p "$deployment_root" || die "Failed to create deployment root: $deployment_root"
260257
cd "$deployment_root" || die "Cannot change to deployment root: $deployment_root"
261258

262-
acquire_lock "$deployment_root"
259+
acquire_lock "."
263260

264261
create_directory_structure "$deployment_root"
265262

266-
readonly release_id="$(generate_release_id)"
263+
local release_id
264+
release_id="$(generate_release_id)"
265+
readonly release_id
267266
# Absolute path for logging/external use; activate_release uses relative paths
268267
# since we've cd'd to deployment_root
269268
readonly release_dir="$deployment_root/releases/$release_id"

test-race.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ echo ""
3030
reader_pid=$!
3131

3232
# Writer loop - rapidly swaps symlink using naive approach
33-
for i in {1..1000}; do
33+
for _ in {1..1000}; do
3434
ln -sfn releases/v1 current
3535
ln -sfn releases/v2 current
3636
done

0 commit comments

Comments
 (0)