Archived
Fix codex-maintenance.sh path prefix when run from mono-repo subtree
This commit is contained in:
@@ -37,6 +37,17 @@ source "${script_dir}/lib/nix-parallel.sh"
|
||||
repo_root="$(cd "${script_dir}/.." && pwd)"
|
||||
cd "$repo_root"
|
||||
|
||||
# When this repo is a subdirectory of a larger git repo (e.g. a mono-repo
|
||||
# subtree), `git diff --name-only` outputs paths relative to the outer git
|
||||
# root, not this directory. Compute a prefix to strip so pattern matching
|
||||
# below works correctly regardless of nesting depth.
|
||||
_git_root="$(git rev-parse --show-toplevel 2>/dev/null || echo "$repo_root")"
|
||||
if [[ "$repo_root" != "$_git_root" ]]; then
|
||||
_subtree_prefix="${repo_root#"$_git_root"/}/"
|
||||
else
|
||||
_subtree_prefix=""
|
||||
fi
|
||||
|
||||
full_check=false
|
||||
dry_run=false
|
||||
|
||||
@@ -120,7 +131,7 @@ if ! $full_check; then
|
||||
base_ref="$(resolve_base_ref)"
|
||||
echo
|
||||
echo "Changed-files scope: diffing against ${base_ref}"
|
||||
mapfile -t changed_files < <(git diff --name-only --diff-filter=ACMR "$base_ref" -- . | sort -u)
|
||||
mapfile -t changed_files < <(git diff --name-only --diff-filter=ACMR "$base_ref" -- . | sort -u | sed "s|^${_subtree_prefix}||")
|
||||
|
||||
if [[ ${#changed_files[@]} -eq 0 ]]; then
|
||||
echo "No changed files detected."
|
||||
|
||||
Reference in New Issue
Block a user