diff --git a/README.md b/README.md index 2fcd846..c4a761b 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,11 @@ Useful flags on `clone_and_analyze.py`: --cleanup # remove local clones of repos that succeeded, once the run finishes --dest DIR # where to clone into (default: ~/git/iris-repos) --include-archived # also consider archived repos +--iris-days N # run `iris . --days N` (single window) instead of the default + # RECOMMENDED_WINDOWS set — independent of --days, which only + # controls which repos get selected. E.g. select repos active in + # the last 7 days but analyze each with only the 30-day window: + # --days 7 --iris-days 30 ``` `list_active_repos.py` can also flip the filter to find neglected repos instead: diff --git a/scripts/clone_and_analyze.py b/scripts/clone_and_analyze.py index e21ff42..69808c3 100755 --- a/scripts/clone_and_analyze.py +++ b/scripts/clone_and_analyze.py @@ -3,9 +3,16 @@ Chains with list_active_repos.py: pulls the same "active in the last N days" repo set, clones any repo not already present under --dest (or fast-forward -pulls it if it is), then runs the `iris` CLI inside each repo directory with -no extra flags — identical to a manual `cd && iris` — so metrics push -to the Iris platform per the account's existing `iris login` session. +pulls it if it is), then runs the `iris` CLI inside each repo directory — +by default with no extra flags (identical to a manual `cd && iris`, +analyzing all of RECOMMENDED_WINDOWS), or with a single `--days` window via +--iris-days — so metrics push to the Iris platform per the account's +existing `iris login` session. + +--days selects WHICH repos to process (activity lookback); --iris-days +controls WHAT WINDOW `iris` analyzes once inside each repo. They're +independent: e.g. `--days 7 --iris-days 30` picks repos with a commit in +the last 7 days, then runs `iris . --days 30` in each. One repo failing (clone conflict, analysis error) does not stop the run; a summary of successes/failures prints at the end. @@ -14,7 +21,7 @@ in (`iris auth status`) if you want the push-to-platform behavior. Usage: - python scripts/clone_and_analyze.py --org my-org [--days 90] + python scripts/clone_and_analyze.py --org my-org [--days 90] [--iris-days 30] [--dest ~/git/iris-repos] [--limit N] [--include-archived] [--cleanup] Exit codes: @@ -64,9 +71,10 @@ def sync_repo(name_with_owner: str, dest_dir: Path) -> bool: return True -def run_iris(repo_dir: Path) -> bool: - print(" running iris...") - result = subprocess.run(["iris", "."], cwd=repo_dir, capture_output=True, text=True) +def run_iris(repo_dir: Path, iris_days: int | None) -> bool: + cmd = ["iris", "."] if iris_days is None else ["iris", ".", "--days", str(iris_days)] + print(f" running {' '.join(cmd)}...") + result = subprocess.run(cmd, cwd=repo_dir, capture_output=True, text=True) if result.returncode != 0: print(f" ✗ iris failed: {result.stderr.strip()}", file=sys.stderr) return False @@ -83,6 +91,15 @@ def parse_args() -> argparse.Namespace: choices=CANONICAL_WINDOWS, help=f"lookback window in days, one of {CANONICAL_WINDOWS} (default: 90)", ) + parser.add_argument( + "--iris-days", + type=int, + default=None, + choices=CANONICAL_WINDOWS, + help="if set, run `iris . --days N` with this single window instead of the " + "default RECOMMENDED_WINDOWS set — independent of --days (which only " + "controls repo selection)", + ) parser.add_argument( "--dest", default="~/git/iris-repos", @@ -122,7 +139,7 @@ def main() -> int: if not sync_repo(name, repo_dir): failed.append(name) continue - if not run_iris(repo_dir): + if not run_iris(repo_dir, args.iris_days): failed.append(name) continue succeeded.append(name)