fix(builder): refresh git index before publish gate
This commit is contained in:
@@ -75,6 +75,8 @@ if [[ -z "$dest" && -z "${COPY_SCRIPT:-}" || $# -eq 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$project_root" ]] && git -C "$project_root" rev-parse HEAD >/dev/null 2>&1; then
|
if [[ -n "$project_root" ]] && git -C "$project_root" rev-parse HEAD >/dev/null 2>&1; then
|
||||||
|
# Refresh Git's cached stat data after build tools rewrite tracked files.
|
||||||
|
git -C "$project_root" update-index -q --refresh 2>/dev/null || true
|
||||||
if [[ ${ALLOW_UNCOMMITTED:-0} != 1 ]] && ! git -C "$project_root" diff-index --quiet HEAD -- 2>/dev/null; then
|
if [[ ${ALLOW_UNCOMMITTED:-0} != 1 ]] && ! git -C "$project_root" diff-index --quiet HEAD -- 2>/dev/null; then
|
||||||
echo "Error: working tree has uncommitted changes; refusing to publish." >&2
|
echo "Error: working tree has uncommitted changes; refusing to publish." >&2
|
||||||
echo "Commit first, or set ALLOW_UNCOMMITTED=1 to publish anyway." >&2
|
echo "Commit first, or set ALLOW_UNCOMMITTED=1 to publish anyway." >&2
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ fi
|
|||||||
# Dirty-tree gate: publishing uncommitted content requires explicit opt-in.
|
# Dirty-tree gate: publishing uncommitted content requires explicit opt-in.
|
||||||
if [[ "$mode" == push && "$dry_run" == false && -n "$project_root" ]] \
|
if [[ "$mode" == push && "$dry_run" == false && -n "$project_root" ]] \
|
||||||
&& git -C "$project_root" rev-parse HEAD >/dev/null 2>&1; then
|
&& git -C "$project_root" rev-parse HEAD >/dev/null 2>&1; then
|
||||||
|
git -C "$project_root" update-index -q --refresh 2>/dev/null || true
|
||||||
if [[ ${ALLOW_UNCOMMITTED:-0} != 1 ]] && ! git -C "$project_root" diff-index --quiet HEAD -- 2>/dev/null; then
|
if [[ ${ALLOW_UNCOMMITTED:-0} != 1 ]] && ! git -C "$project_root" diff-index --quiet HEAD -- 2>/dev/null; then
|
||||||
echo "Error: working tree has uncommitted changes; refusing to publish." >&2
|
echo "Error: working tree has uncommitted changes; refusing to publish." >&2
|
||||||
echo "Commit first, or set ALLOW_UNCOMMITTED=1 to publish anyway." >&2
|
echo "Commit first, or set ALLOW_UNCOMMITTED=1 to publish anyway." >&2
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ fi
|
|||||||
|
|
||||||
# Dirty-tree gate: publishing uncommitted content requires explicit opt-in.
|
# Dirty-tree gate: publishing uncommitted content requires explicit opt-in.
|
||||||
if [[ -n "$project_root" ]] && git -C "$project_root" rev-parse HEAD >/dev/null 2>&1; then
|
if [[ -n "$project_root" ]] && git -C "$project_root" rev-parse HEAD >/dev/null 2>&1; then
|
||||||
|
git -C "$project_root" update-index -q --refresh 2>/dev/null || true
|
||||||
if [[ ${ALLOW_UNCOMMITTED:-0} != 1 ]] && ! git -C "$project_root" diff-index --quiet HEAD -- 2>/dev/null; then
|
if [[ ${ALLOW_UNCOMMITTED:-0} != 1 ]] && ! git -C "$project_root" diff-index --quiet HEAD -- 2>/dev/null; then
|
||||||
echo "Error: working tree has uncommitted changes; refusing to publish." >&2
|
echo "Error: working tree has uncommitted changes; refusing to publish." >&2
|
||||||
echo "Commit first, or set ALLOW_UNCOMMITTED=1 to publish anyway." >&2
|
echo "Commit first, or set ALLOW_UNCOMMITTED=1 to publish anyway." >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user