Skip to content

fix(code): fix branch vs default diff for unpushed changes#1874

Open
adboio wants to merge 1 commit into04-23-feat_code_add_pr_comments_to_local_tasksfrom
04-23-fix_code_fix_branch_vs_default_diff_for_unpushed_changes
Open

fix(code): fix branch vs default diff for unpushed changes#1874
adboio wants to merge 1 commit into04-23-feat_code_add_pr_comments_to_local_tasksfrom
04-23-fix_code_fix_branch_vs_default_diff_for_unpushed_changes

Conversation

@adboio
Copy link
Copy Markdown
Contributor

@adboio adboio commented Apr 23, 2026

Problem

when a user has committed but unpushed changes, they do not show up in the "branch vs [default]" diff because we use the github APIs and compare to the remote branch

Changes

updates to use local instead of assuming remote for this case

How did you test this?

manually repro'd and tested after fix

Copy link
Copy Markdown
Contributor Author

adboio commented Apr 23, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@adboio adboio force-pushed the 04-23-feat_code_add_pr_comments_to_local_tasks branch from 8baaf60 to ec729a7 Compare April 24, 2026 21:33
@adboio adboio force-pushed the 04-23-fix_code_fix_branch_vs_default_diff_for_unpushed_changes branch 2 times, most recently from d46c6f4 to a844b47 Compare April 24, 2026 22:14
@adboio adboio force-pushed the 04-23-feat_code_add_pr_comments_to_local_tasks branch from ec729a7 to 83a3771 Compare April 24, 2026 22:14
@adboio adboio force-pushed the 04-23-fix_code_fix_branch_vs_default_diff_for_unpushed_changes branch from a844b47 to c9125cb Compare April 24, 2026 22:29
@adboio adboio force-pushed the 04-23-feat_code_add_pr_comments_to_local_tasks branch 2 times, most recently from a634430 to 7d0719f Compare April 24, 2026 22:47
@adboio adboio force-pushed the 04-23-fix_code_fix_branch_vs_default_diff_for_unpushed_changes branch from c9125cb to 1805acd Compare April 24, 2026 22:47
@adboio adboio marked this pull request as ready for review April 24, 2026 22:49
@adboio adboio requested a review from a team April 24, 2026 22:49
@adboio adboio force-pushed the 04-23-feat_code_add_pr_comments_to_local_tasks branch from 7d0719f to cf00d9b Compare April 24, 2026 22:51
@adboio adboio force-pushed the 04-23-fix_code_fix_branch_vs_default_diff_for_unpushed_changes branch from 1805acd to dbfc625 Compare April 24, 2026 22:52
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 24, 2026

Prompt To Fix All With AI
This is a comment left during a code review.
Path: packages/git/src/queries.test.ts
Line: 101-145

Comment:
**Prefer parameterised tests for `splitUnifiedDiffByFile`**

The four cases for `splitUnifiedDiffByFile` all follow the same pattern — supply a raw diff string, check keys and values in the returned map — and could be collapsed into a single `it.each` table per the team's preference for parameterised tests. The test for the two-file case is the outlier (multiple assertions), but even that can live as a row with a callback to an inline assertion helper.

```ts
it.each([
  ["empty input", "", []],
  ["binary diff", "diff --git a/image.png b/image.png\nBinary files ...", ["image.png"]],
  ["rename keyed by new path", "diff --git a/old.txt b/new.txt\nsimilarity index 100%\n...", ["new.txt"]],
] as const)("splitUnifiedDiffByFile: %s", (_label, raw, expectedKeys) => {
  const result = splitUnifiedDiffByFile(raw);
  expect([...result.keys()]).toEqual(expectedKeys);
});
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(code): fix branch vs default diff fo..." | Re-trigger Greptile

Comment on lines +101 to +145

describe("splitUnifiedDiffByFile", () => {
it("returns an empty map for empty input", () => {
expect(splitUnifiedDiffByFile("")).toEqual(new Map());
});

it("splits a two-file diff keyed by post-image path", () => {
const raw = [
"diff --git a/one.txt b/one.txt",
"index 0000000..1111111 100644",
"--- a/one.txt",
"+++ b/one.txt",
"@@ -1 +1 @@",
"-hello",
"+hello world",
"diff --git a/two.txt b/two.txt",
"new file mode 100644",
"--- /dev/null",
"+++ b/two.txt",
"@@ -0,0 +1 @@",
"+brand new",
"",
].join("\n");

const result = splitUnifiedDiffByFile(raw);

expect([...result.keys()]).toEqual(["one.txt", "two.txt"]);
expect(result.get("one.txt")).toContain("diff --git a/one.txt b/one.txt");
expect(result.get("one.txt")).toContain("+hello world");
expect(result.get("two.txt")).toContain("diff --git a/two.txt b/two.txt");
expect(result.get("two.txt")).toContain("+brand new");
});

it("keys renames by the post-rename (b/) path", () => {
const raw = [
"diff --git a/old.txt b/new.txt",
"similarity index 100%",
"rename from old.txt",
"rename to new.txt",
"",
].join("\n");

const result = splitUnifiedDiffByFile(raw);
expect(result.has("new.txt")).toBe(true);
expect(result.has("old.txt")).toBe(false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Prefer parameterised tests for splitUnifiedDiffByFile

The four cases for splitUnifiedDiffByFile all follow the same pattern — supply a raw diff string, check keys and values in the returned map — and could be collapsed into a single it.each table per the team's preference for parameterised tests. The test for the two-file case is the outlier (multiple assertions), but even that can live as a row with a callback to an inline assertion helper.

it.each([
  ["empty input", "", []],
  ["binary diff", "diff --git a/image.png b/image.png\nBinary files ...", ["image.png"]],
  ["rename keyed by new path", "diff --git a/old.txt b/new.txt\nsimilarity index 100%\n...", ["new.txt"]],
] as const)("splitUnifiedDiffByFile: %s", (_label, raw, expectedKeys) => {
  const result = splitUnifiedDiffByFile(raw);
  expect([...result.keys()]).toEqual(expectedKeys);
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/git/src/queries.test.ts
Line: 101-145

Comment:
**Prefer parameterised tests for `splitUnifiedDiffByFile`**

The four cases for `splitUnifiedDiffByFile` all follow the same pattern — supply a raw diff string, check keys and values in the returned map — and could be collapsed into a single `it.each` table per the team's preference for parameterised tests. The test for the two-file case is the outlier (multiple assertions), but even that can live as a row with a callback to an inline assertion helper.

```ts
it.each([
  ["empty input", "", []],
  ["binary diff", "diff --git a/image.png b/image.png\nBinary files ...", ["image.png"]],
  ["rename keyed by new path", "diff --git a/old.txt b/new.txt\nsimilarity index 100%\n...", ["new.txt"]],
] as const)("splitUnifiedDiffByFile: %s", (_label, raw, expectedKeys) => {
  const result = splitUnifiedDiffByFile(raw);
  expect([...result.keys()]).toEqual(expectedKeys);
});
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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