Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
working-directory: apps/pr-reviewer
steps:
- uses: actions/checkout@v4
with:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shallow checkout breaks PR diff

High Severity

Removing fetch-depth: 0 makes actions/checkout@v4 use its default depth of 1, so the clone has only the triggering commit. The later git diff origin/${{ github.base_ref }}...HEAD needs that base ref and the merge-base, which a shallow checkout does not provide. The export step fails and the review agent never runs.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 329a953. Configure here.

fetch-depth: 0
- uses: actions/setup-node@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The git diff command will fail because the default shallow clone (fetch-depth: 1) lacks the necessary history to find the merge base for a three-dot diff.
Severity: HIGH

Suggested Fix

To ensure the git diff command can find the merge base, configure the actions/checkout@v4 step to perform a full clone by setting fetch-depth: 0. This provides the complete git history needed for the operation to succeed.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: .github/workflows/review.yml#L29

Potential issue: The workflow uses `actions/checkout@v4` with its default shallow clone
setting (`fetch-depth: 1`). A subsequent step runs `git diff origin/${{ github.base_ref
}}...HEAD` to generate a diff for the review agent. This three-dot diff command requires
access to the repository's history to find the merge base between the base branch and
the pull request's HEAD. In a shallow clone, this history is missing, which will cause
the `git diff` command to fail and halt the workflow. Since there is no error handling,
the review agent will not run.

Did we get this right? 👍 / 👎 to inform future reviews.

with:
node-version: 22
Expand Down
8 changes: 8 additions & 0 deletions apps/pr-reviewer/fixtures/demo-pr/loyalty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,12 @@ describe('pointsFor', () => {
it('returns a whole number', () => {
expect(Number.isInteger(pointsFor(777))).toBe(true);
});

it('awards 2 points per dollar to gold members', () => {
expect(pointsFor(10_000, 'gold')).toBe(200);
});

it('defaults to the standard tier', () => {
expect(pointsFor(10_000, 'standard')).toBe(pointsFor(10_000));
});
});
10 changes: 7 additions & 3 deletions apps/pr-reviewer/fixtures/demo-pr/loyalty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** One and a half points per whole dollar spent, rounded once after the multiplier. */
export function pointsFor(totalCents: number): number {
return Math.round((totalCents / 100) * 1.5);
export type LoyaltyTier = 'standard' | 'gold';

const TIER_MULTIPLIER: Record<LoyaltyTier, number> = { standard: 1.5, gold: 2 };

/** Points per whole dollar spent depend on the tier, rounded once after the multiplier. */
export function pointsFor(totalCents: number, tier: LoyaltyTier = 'standard'): number {
return Math.round((totalCents / 100) * TIER_MULTIPLIER[tier]);
}
Loading