mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-04 15:57:33 +01:00
fix: pre-landing review fixes
Leave an unmerged VERSION to the rescue, keep the enclosing project's fsmonitor hook from running during the preflight, and word the version-reverted refusal for a hand edit as well as a project checkout. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
fdd5169a34
commit
c626eceabc
2 files changed
+33
-5
No files matched your search
@@ -73,13 +73,14 @@ g() { git -c core.fsmonitor=false -c core.splitIndex=false "$@"; }
|
||||
_PF=$(
|
||||
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_OBJECT_DIRECTORY
|
||||
cd -- "$DIR/.." 2>/dev/null || exit 0
|
||||
_top=$(git rev-parse --show-toplevel 2>/dev/null) || exit 0
|
||||
_rel="$(git rev-parse --show-prefix 2>/dev/null)${DIR##*/}" || exit 0
|
||||
pg() { git -c core.fsmonitor=false -c core.splitIndex=false "$@"; }
|
||||
_top=$(pg rev-parse --show-toplevel 2>/dev/null) || exit 0
|
||||
_rel="$(pg rev-parse --show-prefix 2>/dev/null)${DIR##*/}" || exit 0
|
||||
_n=0
|
||||
while IFS= read -r _l; do
|
||||
case "$_l" in (''|'160000 '*) ;; (*) _n=$((_n + 1)) ;; esac
|
||||
done <<EOF_PF
|
||||
$(git -C "$_top" --literal-pathspecs ls-files -s -- "$_rel" 2>/dev/null)
|
||||
$(pg -C "$_top" --literal-pathspecs ls-files -s -- "$_rel" 2>/dev/null)
|
||||
EOF_PF
|
||||
[ "$_n" -gt 0 ] && printf '%s\n%s\n%s\n' "$_top" "$_rel" "$_n"
|
||||
)
|
||||
@@ -87,11 +88,12 @@ if [ -n "$_PF" ]; then
|
||||
_top=$(printf '%s\n' "$_PF" | sed -n 1p) _rel=$(printf '%s\n' "$_PF" | sed -n 2p) _n=$(printf '%s\n' "$_PF" | sed -n 3p)
|
||||
refuse 6 tracked-by-project "$_top tracks $_n files of the gstack install at $_rel, so every checkout there puts old gstack files back (VERSION frozen, #1022); nothing was changed; fix: git -C $(ff_quote "$_top") rm -r -q --cached -- $(ff_quote "$_rel"), add /$_rel/ to $(ff_quote "$_top/.gitignore") and commit both on every branch you check out (or vendor gstack as a git submodule), then git -C $(ff_quote "$DIR") stash push -m 'files reverted by the project' (keeps every edit) and re-run" 900
|
||||
fi
|
||||
if g cat-file -e HEAD:VERSION 2>/dev/null; then
|
||||
# An unmerged VERSION is left to the rescue below.
|
||||
if g cat-file -e HEAD:VERSION 2>/dev/null && [ -z "$(g ls-files -u -- VERSION 2>/dev/null)" ]; then
|
||||
g diff --quiet HEAD -- VERSION 2>/dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
_have=$(head -1 VERSION 2>/dev/null | tr -d '\r') _want=$(g show HEAD:VERSION 2>/dev/null | head -1 | tr -d '\r')
|
||||
refuse 6 version-reverted "VERSION says ${_have:-nothing} but the checkout is at $_want: something outside git put old gstack files back (an enclosing project's checkout, #1022); nothing was changed; fix: git -C $(ff_quote "$DIR") stash push -m 'files reverted by the project' (keeps every edit), then re-run" 900
|
||||
refuse 6 version-reverted "VERSION says ${_have:-nothing} but the checkout is at $_want: files changed outside git (an enclosing project's checkout puts old ones back, #1022, or a hand edit); nothing was changed; fix: git -C $(ff_quote "$DIR") stash push -m 'files reverted by the project' (keeps every edit), then re-run" 900
|
||||
fi
|
||||
fi
|
||||
[ "$PREFLIGHT" -eq 1 ] && exit 0
|
||||
|
||||
@@ -289,6 +289,32 @@ describe.skipIf(process.platform === 'win32')('gstack-ff-update: moving the tree
|
||||
expect(reverted.status).toBe(6);
|
||||
expect(reverted.stdout).toStartWith('version-reverted: VERSION says 1.0.0 but the checkout is at 1.1.0');
|
||||
expect(read(fx, 'VERSION')).toBe('1.0.0\n');
|
||||
write(fx, 'VERSION', '9.9.9\n');
|
||||
expect(ff(fx).stdout).toStartWith('version-reverted: VERSION says 9.9.9 but the checkout is at 1.1.0: files changed outside git');
|
||||
});
|
||||
|
||||
// Value: protects=an unmerged VERSION still takes the existing rescue, which the unmerged-files banner's command relies on;
|
||||
// fails_when=the version-reverted preflight fires on conflict markers; why_new=the preflight is new; seam=none
|
||||
test('preflight: an unmerged VERSION is rescued, not refused as version-reverted', () => {
|
||||
const fx = makeFixture();
|
||||
makeUnmerged(fx, 'VERSION');
|
||||
const target = release(fx, { 'notes.txt': 'x\n' });
|
||||
const r = ff(fx, target);
|
||||
expect(r.status, r.stdout + r.stderr).toBe(0);
|
||||
expect(r.stdout).toMatch(/^rescued .* unmerged=1/);
|
||||
});
|
||||
|
||||
// Value: protects=the preflight runs no code from the enclosing project (its core.fsmonitor hook); fails_when=an enclosing-repo git call
|
||||
// drops the fsmonitor override; why_new=the enclosing-project probe is new; seam=none
|
||||
test('preflight: an enclosing project\'s core.fsmonitor hook never runs', () => {
|
||||
const fx = makeFixture();
|
||||
const sentinel = path.join(fx.base, 'fsmonitor-ran');
|
||||
git(fx.base, 'init', '-q', '-b', 'main');
|
||||
fs.writeFileSync(path.join(fx.base, 'hook.sh'), `#!/bin/sh\ntouch '${sentinel}'\n`, { mode: 0o755 });
|
||||
git(fx.base, 'config', 'core.fsmonitor', path.join(fx.base, 'hook.sh'));
|
||||
const r = spawnSync('bash', [FF, '--preflight', fx.install], { encoding: 'utf8', env: isolatedEnv(fx.base), timeout: 60_000 });
|
||||
expect(r.status, r.stdout + r.stderr).toBe(0);
|
||||
expect(fs.existsSync(sentinel)).toBe(false);
|
||||
});
|
||||
|
||||
test('refusals: not a fast-forward, an unresolvable target, and a missing checkout', () => {
|
||||
|
||||
Reference in new issue
Block a user