mirror of https://github.com/garrytan/gstack.git
fix(update-check): --force now clears snooze so user can upgrade after snoozing
When a user snoozes an upgrade notification but then changes their mind and runs `/gstack-upgrade` directly, the --force flag should allow them to proceed. Previously, --force only cleared the cache but still respected the snooze, leaving the user unable to upgrade until the snooze expired. Now --force clears both cache and snooze, matching user intent: "I want to upgrade NOW, regardless of previous dismissals." Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
bd834aeadb
commit
56596f5b43
|
|
@ -20,9 +20,10 @@ SNOOZE_FILE="$STATE_DIR/update-snoozed"
|
||||||
VERSION_FILE="$GSTACK_DIR/VERSION"
|
VERSION_FILE="$GSTACK_DIR/VERSION"
|
||||||
REMOTE_URL="${GSTACK_REMOTE_URL:-https://raw.githubusercontent.com/garrytan/gstack/main/VERSION}"
|
REMOTE_URL="${GSTACK_REMOTE_URL:-https://raw.githubusercontent.com/garrytan/gstack/main/VERSION}"
|
||||||
|
|
||||||
# ─── Force flag (busts cache for standalone /gstack-upgrade) ──
|
# ─── Force flag (busts cache + snooze for standalone /gstack-upgrade) ──
|
||||||
if [ "${1:-}" = "--force" ]; then
|
if [ "${1:-}" = "--force" ]; then
|
||||||
rm -f "$CACHE_FILE"
|
rm -f "$CACHE_FILE"
|
||||||
|
rm -f "$SNOOZE_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ─── Step 0: Check if updates are disabled ────────────────────
|
# ─── Step 0: Check if updates are disabled ────────────────────
|
||||||
|
|
|
||||||
|
|
@ -447,6 +447,24 @@ describe('gstack-update-check', () => {
|
||||||
expect(cache).toContain('UP_TO_DATE');
|
expect(cache).toContain('UP_TO_DATE');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('--force clears snooze so user can upgrade after snoozing', () => {
|
||||||
|
writeFileSync(join(gstackDir, 'VERSION'), '0.3.3\n');
|
||||||
|
writeFileSync(join(gstackDir, 'REMOTE_VERSION'), '0.4.0\n');
|
||||||
|
writeSnooze('0.4.0', 1, nowEpoch() - 60); // snoozed 1 min ago (within 24h)
|
||||||
|
|
||||||
|
// Without --force: snoozed, silent
|
||||||
|
const snoozed = run();
|
||||||
|
expect(snoozed.exitCode).toBe(0);
|
||||||
|
expect(snoozed.stdout).toBe('');
|
||||||
|
|
||||||
|
// With --force: snooze cleared, outputs upgrade
|
||||||
|
const forced = run({}, ['--force']);
|
||||||
|
expect(forced.exitCode).toBe(0);
|
||||||
|
expect(forced.stdout).toBe('UPGRADE_AVAILABLE 0.3.3 0.4.0');
|
||||||
|
// Snooze file should be deleted
|
||||||
|
expect(existsSync(join(stateDir, 'update-snoozed'))).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
// ─── Split TTL tests ─────────────────────────────────────────
|
// ─── Split TTL tests ─────────────────────────────────────────
|
||||||
|
|
||||||
test('UP_TO_DATE cache expires after 60 min (not 720)', () => {
|
test('UP_TO_DATE cache expires after 60 min (not 720)', () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue