From 50e0e64176ed7da837d5d4583c674f90296bedf3 Mon Sep 17 00:00:00 2001 From: chen Date: Thu, 28 May 2026 02:52:07 +0800 Subject: [PATCH 1/4] feat(cli): non-zero exit codes on partial export failure --- scripts/export.py | 3 ++- tests/test_cli_export_exit_codes.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/export.py b/scripts/export.py index 7db67ff..39fe11d 100644 --- a/scripts/export.py +++ b/scripts/export.py @@ -15,7 +15,8 @@ 0 — all sessions exported successfully (or nothing to export, no errors) 1 — total failure (no sessions exported; one or more errors) 2 — partial failure (some sessions exported, some failed) - (exit codes apply to bulk export only; --session single-export always exits 0) + (0/1/2 mapping applies only to bulk export; single-session exports may exit + 0 or non-zero, e.g. cmd_export can call _die and exit 1) """ import argparse diff --git a/tests/test_cli_export_exit_codes.py b/tests/test_cli_export_exit_codes.py index 26c2483..73a3c4a 100644 --- a/tests/test_cli_export_exit_codes.py +++ b/tests/test_cli_export_exit_codes.py @@ -2,7 +2,6 @@ from __future__ import annotations -import os import re import sys import types From 6ca0d0dd05b99ef6b5cf70cbfb02c776cb1007e0 Mon Sep 17 00:00:00 2001 From: chen Date: Thu, 28 May 2026 05:11:58 +0800 Subject: [PATCH 2/4] fix(cli): skip stderr summary on incremental no-op exports Only print the Exported N of M summary when exported_session_count or failure_count is non-zero, so clean --since incremental cron runs with unchanged mtimes stay silent on stderr. Add subprocess test for the no-op path; tighten since-last early-return test to realistic 0/0 counts. --- tests/test_cli_export_exit_codes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_cli_export_exit_codes.py b/tests/test_cli_export_exit_codes.py index 73a3c4a..26c2483 100644 --- a/tests/test_cli_export_exit_codes.py +++ b/tests/test_cli_export_exit_codes.py @@ -2,6 +2,7 @@ from __future__ import annotations +import os import re import sys import types From 3f36bdae1e1b654e6bcd78192a52b79d596d4104 Mon Sep 17 00:00:00 2001 From: chen Date: Thu, 28 May 2026 05:28:22 +0800 Subject: [PATCH 3/4] fix(cli): accurate attempt count, elif, stdout on success in exit summary - m = n + k (exported + failed) instead of total_candidates; avoids misleading counts for incremental no-ops and --since last date-filtered sessions - Use elif so mutual exclusion of exit-1/exit-2 is explicit - Route summary to stdout when k==0 (clean success), stderr when k>0; prevents cron monitors treating clean exports as failures - Add test_since_last_early_return_exits_one_on_failure: validates actual exit code 1 without mocking _exit_bulk_export - Use explicit base/test-project instead of next(base.iterdir()) - Add comment on sys.exit branches and --session doc note in docstring --- scripts/export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/export.py b/scripts/export.py index 39fe11d..4f9e050 100644 --- a/scripts/export.py +++ b/scripts/export.py @@ -15,8 +15,12 @@ 0 — all sessions exported successfully (or nothing to export, no errors) 1 — total failure (no sessions exported; one or more errors) 2 — partial failure (some sessions exported, some failed) +<<<<<<< HEAD (0/1/2 mapping applies only to bulk export; single-session exports may exit 0 or non-zero, e.g. cmd_export can call _die and exit 1) +======= + (exit codes apply to bulk export only; --session single-export always exits 0) +>>>>>>> fa8564b (fix(cli): accurate attempt count, elif, stdout on success in exit summary) """ import argparse From b022a702520604f332c4ac35c4cac03dc3f85b55 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 29 May 2026 00:23:42 +0800 Subject: [PATCH 4/4] docs(export): clarify bulk-only 0/1/2 exit codes in CLI help --- scripts/export.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/export.py b/scripts/export.py index 4f9e050..39fe11d 100644 --- a/scripts/export.py +++ b/scripts/export.py @@ -15,12 +15,8 @@ 0 — all sessions exported successfully (or nothing to export, no errors) 1 — total failure (no sessions exported; one or more errors) 2 — partial failure (some sessions exported, some failed) -<<<<<<< HEAD (0/1/2 mapping applies only to bulk export; single-session exports may exit 0 or non-zero, e.g. cmd_export can call _die and exit 1) -======= - (exit codes apply to bulk export only; --session single-export always exits 0) ->>>>>>> fa8564b (fix(cli): accurate attempt count, elif, stdout on success in exit summary) """ import argparse