Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .agents/scripts/auto-update-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@
local needs_check=true
if [[ -n "$last_upstream_check" ]]; then
local last_epoch now_epoch elapsed
if [[ "$(uname)" == "Darwin" ]]; then

Check warning on line 931 in .agents/scripts/auto-update-helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of using the literal 'Darwin' 7 times.

See more on https://sonarcloud.io/project/issues?id=marcusquinn_aidevops&issues=AZzroiodpV0X0E10kf4u&open=AZzroiodpV0X0E10kf4u&pullRequest=4749
last_epoch=$(TZ=UTC date -j -f "%Y-%m-%dT%H:%M:%SZ" "$last_upstream_check" "+%s" 2>/dev/null || echo "0")
else
last_epoch=$(date -d "$last_upstream_check" "+%s" 2>/dev/null || echo "0")
Expand Down Expand Up @@ -1073,6 +1073,28 @@
else
log_error "setup.sh failed during stale-agent re-deploy (exit code: $?)"
fi
else
# VERSION matches but scripts may still differ — a script fix merged without
# a version bump leaves the deployed copy stale until setup.sh is run manually.
# Detect this by comparing SHA-256 of a sentinel script that is frequently
# patched (gh-failure-miner-helper.sh). If it drifts, re-deploy all agents.
# GH#4727: Codacy not_collected false-positive recurred because the fix in
# PR #4704 was not deployed to ~/.aidevops/ before the next pulse cycle.
local sentinel_repo="$INSTALL_DIR/.agents/scripts/gh-failure-miner-helper.sh"
local sentinel_deployed="$HOME/.aidevops/agents/scripts/gh-failure-miner-helper.sh"
if [[ -f "$sentinel_repo" && -f "$sentinel_deployed" ]]; then
local hash_repo hash_deployed
hash_repo=$(sha256sum "$sentinel_repo" 2>/dev/null | awk '{print $1}' || shasum -a 256 "$sentinel_repo" 2>/dev/null | awk '{print $1}' || echo "")
hash_deployed=$(sha256sum "$sentinel_deployed" 2>/dev/null | awk '{print $1}' || shasum -a 256 "$sentinel_deployed" 2>/dev/null | awk '{print $1}' || echo "")
if [[ -n "$hash_repo" && -n "$hash_deployed" && "$hash_repo" != "$hash_deployed" ]]; then
log_warn "Script drift detected (sentinel hash mismatch at v$current) — re-deploying agents..."
if bash "$INSTALL_DIR/setup.sh" --non-interactive >>"$LOG_FILE" 2>&1; then
log_info "Agents re-deployed after script drift (v$current)"
else
log_error "setup.sh failed during script-drift re-deploy (exit code: $?)"
fi
fi
fi
fi

run_freshness_checks
Expand Down Expand Up @@ -1400,7 +1422,7 @@
local launchctl_info
launchctl_info=$(launchctl list 2>/dev/null | grep -F "$LAUNCHD_LABEL" || true)
local pid exit_code interval
pid=$(echo "$launchctl_info" | awk '{print $1}')

Check warning on line 1425 in .agents/scripts/auto-update-helper.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of using the literal '{print $1}' 6 times.

See more on https://sonarcloud.io/project/issues?id=marcusquinn_aidevops&issues=AZzroiodpV0X0E10kf4v&open=AZzroiodpV0X0E10kf4v&pullRequest=4749
exit_code=$(echo "$launchctl_info" | awk '{print $2}')
echo -e " Scheduler: launchd (macOS LaunchAgent)"
echo -e " Status: ${GREEN}loaded${NC}"
Expand Down
Loading