From e6d4a4aa48070dfe853334bdbbc706cc54011130 Mon Sep 17 00:00:00 2001 From: Dan Notestein Date: Fri, 9 Jan 2026 02:14:31 -0500 Subject: [PATCH] Fix: use git -C to avoid changing working directory The previous code did 'cd $WORK_DIR' which caused the output file to be written to the temp directory instead of the project directory. This broke artifact uploads. Use 'git -C $WORK_DIR' instead to run git commands without changing the current directory. --- scripts/bash/find-upstream-image.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/bash/find-upstream-image.sh b/scripts/bash/find-upstream-image.sh index 525cb5b..df84684 100755 --- a/scripts/bash/find-upstream-image.sh +++ b/scripts/bash/find-upstream-image.sh @@ -192,10 +192,9 @@ git clone --depth="$DEPTH" --branch="$BRANCH" --single-branch "$REPO_URL" "$WORK log "Finding source commits for patterns: ${PATTERN_ARRAY[*]}" log "Will check up to $MAX_SEARCH commits for existing images" -cd "$WORK_DIR" - # Get list of commits that changed source files (most recent first) -mapfile -t SOURCE_COMMITS < <(git log --pretty=format:"%H" -n "$MAX_SEARCH" -- "${PATTERN_ARRAY[@]}" 2>/dev/null || true) +# Use git -C to avoid changing directories (keeps OUTPUT_FILE path correct) +mapfile -t SOURCE_COMMITS < <(git -C "$WORK_DIR" log --pretty=format:"%H" -n "$MAX_SEARCH" -- "${PATTERN_ARRAY[@]}" 2>/dev/null || true) if [[ ${#SOURCE_COMMITS[@]} -eq 0 ]]; then error "Failed to find any source commits matching patterns" -- GitLab