mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-03-25 09:25:51 +00:00
feat: Abort on no changes
This commit is contained in:
parent
66d50474f5
commit
aebc442880
2 changed files with 26 additions and 0 deletions
|
|
@ -61,7 +61,20 @@ TRACKER_ARGS=()
|
|||
if [[ -n "${STORES:-}" ]]; then
|
||||
TRACKER_ARGS+=(--stores "${STORES}")
|
||||
fi
|
||||
set +e
|
||||
"$NODE_BIN" bin/tracker.js "${TRACKER_ARGS[@]}"
|
||||
rc=$?
|
||||
set -e
|
||||
|
||||
if [[ $rc -eq 3 ]]; then
|
||||
echo "No meaningful changes; resetting worktree and skipping commit." >&2
|
||||
git reset --hard -q
|
||||
git clean -fdq -- reports data/db viz/data
|
||||
exit 0
|
||||
fi
|
||||
if [[ $rc -ne 0 ]]; then
|
||||
exit $rc
|
||||
fi
|
||||
|
||||
# Build viz artifacts on the data branch
|
||||
"$NODE_BIN" tools/build_viz_index.js
|
||||
|
|
|
|||
13
src/main.js
13
src/main.js
|
|
@ -156,12 +156,25 @@ async function main() {
|
|||
|
||||
const report = await runAllStores(storesToRun, { config, logger, http });
|
||||
|
||||
const meaningful =
|
||||
(report?.totals?.newCount || 0) +
|
||||
(report?.totals?.updatedCount || 0) +
|
||||
(report?.totals?.removedCount || 0) +
|
||||
(report?.totals?.restoredCount || 0) >
|
||||
0;
|
||||
|
||||
const reportTextColor = renderFinalReport(report, {
|
||||
dbDir: config.dbDir,
|
||||
colorize: logger.colorize,
|
||||
});
|
||||
process.stdout.write(reportTextColor);
|
||||
|
||||
if (!meaningful) {
|
||||
logger.ok("No meaningful changes; skipping report write.");
|
||||
process.exitCode = 3; // special "no-op" code
|
||||
return;
|
||||
}
|
||||
|
||||
const reportTextPlain = renderFinalReport(report, {
|
||||
dbDir: config.dbDir,
|
||||
colorize: false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue