Skip to content

feat(cli): gitpulse:ignore label excludes PRs from publication#58

Merged
znat merged 2 commits into
mainfrom
feat/ignore-label
May 19, 2026
Merged

feat(cli): gitpulse:ignore label excludes PRs from publication#58
znat merged 2 commits into
mainfrom
feat/ignore-label

Conversation

@znat
Copy link
Copy Markdown
Owner

@znat znat commented May 18, 2026

Summary

  • Adds a gitpulse:ignore PR label that drops the labelled PR's story from the publication. The label set on GitHub is the source of truth — every analyzer run re-reads labels and rebuilds, so retroactive labelling prunes old stories and removing the label re-publishes them (subject to the bootstrap window).
  • Configurable via .gitpulse.json under labels.ignore; defaults to gitpulse:ignore. The object shape leaves room for group / regenerate later without another schema migration.
  • Two interception points: an up-front GraphQL search sweep (catches retroactively-labelled PRs) and a per-commit ctx.pr.labels check inside processCommit (handles the edge case where the label landed between sweep and fetch).

Usage

```fish
gh label create gitpulse:ignore --color cccccc --description "Excluded from gitpulse publication"
gh pr edit 45 --add-label gitpulse:ignore
```

Or with a custom name in `.gitpulse.json`:
```json
{ "labels": { "ignore": "team:skip" } }
```

Files

  • `cli/src/labels.ts` (new) — `DEFAULT_LABELS` map.
  • `cli/src/project-config.ts` — optional `labels: { ignore? }` on schema; `ProjectConfigSchema` is now exported for tests.
  • `cli/src/config.ts` — resolves `cfg.labels.ignore` with default fallback.
  • `cli/src/github.ts` — `labels` field added to PR GraphQL + `PRData`; new `listLabeledPRs(owner, repo, label)` with pagination and graceful error handling.
  • `cli/src/ignore-sweep.ts` (new) — pure `applyIgnoreSweep` helper, deletes `pr-.json` for ignored PRs and returns the SHA set.
  • `cli/src/index.ts` — sweep after `walkCommits`, `newCommits` filter, per-commit label check in `processCommit`, `skipped` flag on `ProcessOk`.

Limitations

  • Only applies to PRs — direct-push commits cannot be ignored via labels.
  • Removing the label only re-publishes the story if the merge commit is still inside `cfg.bootstrapDays`.
  • One GraphQL search call per analyzer run (paginates beyond 100 PRs).

Test plan

  • `yarn test` in `cli/` — 97/97 pass (added 14 new cases across 3 files).
  • `yarn typecheck` in `cli/` — clean.
  • `yarn test` in `site/` — 107/107 still pass (no site changes).
  • Manual end-to-end on a real deploy: apply the label to a noisy PR, run analyzer, confirm `pr-.json` is deleted and the manifest entry drops out.
  • Reversibility: remove the label, re-run, confirm the story reappears (commit must be inside the bootstrap window).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Label-based filtering to skip PRs from analysis and story generation
    • Configure a custom ignore label in project config to auto-skip matching PRs
    • Skipped PRs are excluded from processing and counted separately; previously generated data for ignored PRs is cleaned up automatically
  • Tests

    • Added tests covering label handling, listing labeled PRs (including pagination and error cases), and the ignore-sweep cleanup behavior

Review Change Stack

Apply `gitpulse:ignore` to a merged PR to drop its story from the
timeline. The label is the durable state — every analyzer run re-reads
labels and rebuilds, so retroactive labeling prunes old stories and
removing the label re-publishes them (within the bootstrap window).

Label name is configurable via `.gitpulse.json` under
`labels.ignore`; the object shape leaves room for future actions
(group, regenerate) without further schema changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 502dae2b-edb0-43a9-a1c4-cb0fd06f6a16

📥 Commits

Reviewing files that changed from the base of the PR and between 7b20af9 and 9e059a0.

📒 Files selected for processing (1)
  • cli/src/github.ts

📝 Walkthrough

Walkthrough

Adds configurable PR curation via an "ignore" label: schema and defaults, GitHub label fetching and search, an ignore-sweep to remove restored story files, and analyzer integration to skip processing ignored PRs and exclude their SHAs.

Changes

PR Label Curation

Layer / File(s) Summary
Label constants, schema, and config
cli/src/labels.ts, cli/src/project-config.ts, cli/src/project-config.test.ts, cli/src/config.ts
Adds DEFAULT_LABELS (ignore: 'gitpulse:ignore'), LabelsSchema to ProjectConfigSchema, tests for label parsing/validation, and extends RuntimeConfig with labels.ignore (falls back to default).
GitHub API label fetching and search
cli/src/github.ts, cli/src/github.test.ts
Adds labels: string[] to PRData, updates commit-context query to fetch PR labels, adds LABEL_SEARCH_QUERY and typings, implements GitHubClient.listLabeledPRs() with cursor pagination and error handling, and tests mapping, null-merge filtering, error path, and pagination.
Ignore sweep utility
cli/src/ignore-sweep.ts, cli/src/ignore-sweep.test.ts
Adds applyIgnoreSweep() and types to delete stories/pr-<n>.json for ignored PRs, return a set of ignored SHAs and removed count; tests verify deletion, no-file behavior, and empty-ignore no-op.
Analyzer ignore label integration
cli/src/index.ts
Imports and runs ignore-sweep when available, filters commit window by ignored SHAs, adds a fast-path in processCommit to return { skipped: true } when PR has the ignore label, extends ProcessOk with optional skipped, and updates per-commit accounting and console output for skipped vs processed commits.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through labels bright,
Finds the PRs it needs to spare,
Stories pruned with gentle might,
Skips the noise and leaves room to care.
Hooray for tidy curation — hop, hop, hooray! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(cli): gitpulse:ignore label excludes PRs from publication' accurately and specifically describes the main feature being added—a configurable label that prevents labeled PRs from being published.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ignore-label

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Vercel preview — built from 9e059a0a73288c716c18ca0970e3905738bcd1bb

https://gitpulse-demo-mun84qm4x-znats-projects.vercel.app

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cli/src/github.ts`:
- Around line 137-139: The GraphQL query currently requests labels(first: 20),
which can miss ignore labels and break the per-commit skip check; change that to
labels(first: 100) in the GraphQL query in github.ts so up to 100 labels are
returned, and ensure the per-commit skip check (the commit-skip/ignore logic)
uses the returned nodes { name } as before without truncation.
- Line 306: The interpolated label is used directly in the GitHub search query
and must be escaped to avoid breaking the query when it contains backslashes or
double quotes; before constructing the query string (the line with query:
`repo:${owner}/${repo} is:pr is:merged label:"${label}"`) create a safeLabel by
replacing backslashes with `\\` and double quotes with `\"` (escape backslash
first), then use label:"${safeLabel}" in the query; update the code where
`label` is referenced to use this escaped variable so user-configured labels
cannot break the search.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 896c8eab-4de5-44e8-a399-1e5c1b0b4281

📥 Commits

Reviewing files that changed from the base of the PR and between d9c6605 and 7b20af9.

📒 Files selected for processing (9)
  • cli/src/config.ts
  • cli/src/github.test.ts
  • cli/src/github.ts
  • cli/src/ignore-sweep.test.ts
  • cli/src/ignore-sweep.ts
  • cli/src/index.ts
  • cli/src/labels.ts
  • cli/src/project-config.test.ts
  • cli/src/project-config.ts

Comment thread cli/src/github.ts Outdated
Comment thread cli/src/github.ts Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 1 file(s) based on 2 unresolved review comments.

Files modified:

  • cli/src/github.ts

Commit: 9e059a0a73288c716c18ca0970e3905738bcd1bb

The changes have been pushed to the feat/ignore-label branch.

Time taken: 2m 34s

Fixed 1 file(s) based on 2 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@znat znat merged commit cb08c95 into main May 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant