Feature/index push pr#20
Conversation
Feature/style config
Feature/style config
Replace direct-to-main push with PR-based workflow. Uses a persistent branch 'code-to-docs/update-indexes' and creates/updates a single PR. Concurrent runs are handled safely with --force-with-lease. Removes the complex branch-switching/stash/cherry-pick logic in favor of a simpler flow: backup index files, checkout index branch from base, restore files, commit, push, create/update PR, return to original branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 4:24 PM UTC · Completed 4:45 PM UTC |
ReviewFindingsMedium
Low
Previous runReviewFindingsHigh
Medium
Low
Info
|
| @@ -689,157 +686,92 @@ def commit_indexes_to_repo(content_type="indexes"): | |||
| print(f"No {content_type} changes to commit") | |||
There was a problem hiding this comment.
[medium] logic-error
The old code had merge-base checking and selective summary push logic to prevent older branches from overwriting newer indexes. The new code removes this entirely. In concurrent CI runs, last writer wins. The PR-based workflow partially mitigates this with a human review gate.
| return updated_folders | ||
|
|
||
|
|
||
| INDEX_BRANCH = "code-to-docs/update-indexes" |
There was a problem hiding this comment.
[medium] scope-creep
PR frames this as preventing branch protection bypass but also removes sophisticated branch-currency logic and selective summary pushing. The combined scope should be explicitly acknowledged.
| check=True | ||
| ) | ||
| current_branch = current_branch_result.stdout.strip() | ||
|
|
There was a problem hiding this comment.
[low] logic-error
git stash --include-untracked called before try block. If stash saved nothing, git stash pop in finally will pop a previous stash entry. Pre-existing pattern from old code.
| gh_token = os.environ.get("GH_TOKEN") | ||
| if not gh_token: | ||
| print("Warning: GH_TOKEN not set, cannot create index PR") | ||
| return False |
There was a problem hiding this comment.
[low] error-handling
temp_dir created before inner try/finally block; if shutil.copytree fails before entering try, the temp directory leaks. Pre-existing pattern, minimal impact in CI.
| if not gh_token: | ||
| print("Warning: GH_TOKEN not set, cannot create index PR") | ||
| return False | ||
|
|
There was a problem hiding this comment.
[low] command-injection
DOCS_BASE_BRANCH env var used unsanitized in git commands. Pre-existing issue, env var set by repo admin.
| return updated_folders | ||
|
|
||
|
|
||
| INDEX_BRANCH = "code-to-docs/update-indexes" |
There was a problem hiding this comment.
[low] naming-convention
INDEX_BRANCH constant defined near its consumer function instead of with other module constants at file top.
- README: clarify indexes are submitted via PR, not pushed directly - README: update GH_PAT description to mention index PR creation - Move INDEX_BRANCH constant to module-level with other constants - Remove dead code: doc_matches_main, load_manifest_from_main, get_safe_summaries_to_push (no longer needed with PR-based flow) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 5:55 PM UTC · Completed 6:07 PM UTC |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 6:18 PM UTC · Completed 6:30 PM UTC |
|
Review skipped — this PR is already merged. The Posted by fullsend post-review check |
Summary
Replaces the direct-to-main push of documentation indexes with a PR-based workflow. This prevents bypassing branch protection rules on repos that require PR reviews before merging to main.
What changed
commit_indexes_to_repo()indoc_index.pypreviously switched to the base branch, committed indexes, and pushed directly to main. This involved complex branch-switching, stash, and temp-dir logic that was fragile and bypassed branch protection.Now it:
code-to-docs/update-indexesfrom the latest base--force-with-lease(safe for concurrent runs)Design decisions
code-to-docs/update-indexes. Only one open PR at a time — subsequent runs update it.--force-with-lease: handles concurrent runs safely. If two PRs trigger index updates simultaneously, the last to push wins, the other fails gracefully.Test plan
commit_indexes_to_repowith mocked subprocess calls