Skip to content

Commit 494beba

Browse files
fix(git): align commit-clean test harness with orama guard bundle
Exercise copied scripts under temp repo, bootstrap via commit-clean, fix bare-repo detection in sync-attribution, and empty verify_args under set -u. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 821b985 commit 494beba

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

scripts/git/commit-clean.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ esac
104104
verify_args=()
105105
[[ "$allow_empty" -eq 1 ]] && verify_args+=(--allow-empty)
106106
[[ "$amend" -eq 1 ]] && verify_args+=(--amend)
107-
bash "$SCRIPT_DIR/verify-staged-for-commit.sh" "${verify_args[@]}"
107+
if ((${#verify_args[@]} > 0)); then
108+
bash "$SCRIPT_DIR/verify-staged-for-commit.sh" "${verify_args[@]}"
109+
else
110+
bash "$SCRIPT_DIR/verify-staged-for-commit.sh"
111+
fi
108112

109113
tree="$(git write-tree)"
110114
if [[ "$amend" -eq 1 ]]; then

scripts/git/commit_clean_test.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,30 @@ for helper in commit-clean.sh verify-staged-for-commit.sh banned_attribution_lib
3535
done
3636
printf 'base\n' >"$tmp/README.md"
3737
git -C "$tmp" add README.md
38-
git -C "$tmp" commit -q -m "init"
38+
run_in_repo "$tmp" bash "$tmp/scripts/git/commit-clean.sh" -m "init" >/dev/null
3939

4040
printf 'unstaged only\n' >"$tmp/README.md"
4141

42-
if run_in_repo "$tmp" bash "$SCRIPT_DIR/commit-clean.sh" -m "should fail unstaged" >/dev/null 2>&1; then
42+
if run_in_repo "$tmp" bash "$tmp/scripts/git/commit-clean.sh" -m "should fail unstaged" >/dev/null 2>&1; then
4343
fail "commit-clean must reject unstaged-only working tree"
4444
else
4545
pass "blocks commit when edits are unstaged"
4646
fi
4747

48-
if run_in_repo "$tmp" bash "$SCRIPT_DIR/verify-staged-for-commit.sh" >/dev/null 2>&1; then
48+
if run_in_repo "$tmp" bash "$tmp/scripts/git/verify-staged-for-commit.sh" >/dev/null 2>&1; then
4949
fail "verify-staged must reject empty index"
5050
else
5151
pass "verify-staged rejects empty index"
5252
fi
5353

5454
git -C "$tmp" add README.md
55-
if ! run_in_repo "$tmp" bash "$SCRIPT_DIR/verify-staged-for-commit.sh" >/dev/null 2>&1; then
55+
if ! run_in_repo "$tmp" bash "$tmp/scripts/git/verify-staged-for-commit.sh" >/dev/null 2>&1; then
5656
fail "verify-staged must accept staged delta"
5757
else
5858
pass "verify-staged accepts staged delta"
5959
fi
6060

61-
sha="$(run_in_repo "$tmp" bash "$SCRIPT_DIR/commit-clean.sh" -m "staged commit")"
61+
sha="$(run_in_repo "$tmp" bash "$tmp/scripts/git/commit-clean.sh" -m "staged commit")"
6262
if [[ -z "$sha" ]]; then
6363
fail "commit-clean must return a sha for staged commit"
6464
else

scripts/git/sync-attribution-guard-scripts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ target="${1:?target repo path required}"
66
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
77
source_root="$(cd "$SCRIPT_DIR/../.." && pwd)"
88

9-
if ! git -C "$target" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
9+
if [[ "$(git -C "$target" rev-parse --is-inside-work-tree 2>/dev/null)" != "true" ]]; then
1010
echo "skip: not a git repo: $target" >&2
1111
exit 0
1212
fi

0 commit comments

Comments
 (0)