fix(commit): allow deferred changelog targets
This commit is contained in:
@@ -182,7 +182,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `omp commit` split plans rejecting hunk selectors that resolve to no parsed hunks before resetting the index ([#2098](https://github.com/can1357/oh-my-pi/issues/2098)).
|
||||
- Fixed `omp commit` split plans accepting hunk selectors that resolve to no parsed hunks, which crashed the apply step after the index reset and left the working tree fully unstaged ([#2098](https://github.com/can1357/oh-my-pi/issues/2098)).
|
||||
|
||||
- Fixed inline `find` and `search` result blocks to align with grouped `read` output and render their success headers with the normal tool-title color instead of accent blue.
|
||||
|
||||
|
||||
@@ -692,10 +692,7 @@ export function validateHunkSelections(
|
||||
|
||||
for (const selection of selections) {
|
||||
const fileDiff = fileDiffMap.get(selection.path);
|
||||
if (!fileDiff) {
|
||||
errors.push({ path: selection.path, message: `No diff found for ${selection.path}` });
|
||||
continue;
|
||||
}
|
||||
if (!fileDiff) continue;
|
||||
if (selection.hunks.type === "all") continue;
|
||||
if (fileDiff.isBinary) {
|
||||
errors.push({ path: selection.path, message: `Cannot select hunks for binary file ${selection.path}` });
|
||||
|
||||
@@ -95,4 +95,38 @@ describe("split_commit hunk selector validation", () => {
|
||||
expect(result.details.errors).toContain("Commit 1: No hunks selected for src/a.ts");
|
||||
expect(state.splitProposal).toBeUndefined();
|
||||
});
|
||||
|
||||
it("allows deferred changelog targets that are not in the staged diff yet", async () => {
|
||||
vi.spyOn(git, "diff").mockResolvedValue(STAGED_DIFF);
|
||||
const state: CommitAgentState = {
|
||||
overview: { files: ["src/a.ts", "src/b.ts"], stat: "", numstat: [], scopeCandidates: "", isWideScope: false },
|
||||
};
|
||||
const tool = createSplitCommitTool("/repo", state, ["packages/coding-agent/CHANGELOG.md"]);
|
||||
|
||||
const result = await tool.execute(
|
||||
"split-commit",
|
||||
{
|
||||
commits: [
|
||||
{
|
||||
changes: [
|
||||
{ path: "src/a.ts", hunks: { type: "all" } },
|
||||
{ path: "src/b.ts", hunks: { type: "all" } },
|
||||
{ path: "packages/coding-agent/CHANGELOG.md", hunks: { type: "all" } },
|
||||
],
|
||||
type: "fix",
|
||||
scope: null,
|
||||
summary: "Fixed deferred changelog validation",
|
||||
},
|
||||
],
|
||||
},
|
||||
undefined,
|
||||
{} as never,
|
||||
);
|
||||
|
||||
expect(result.details.valid).toBe(true);
|
||||
expect(result.details.errors).not.toContain("Commit 1: No diff found for packages/coding-agent/CHANGELOG.md");
|
||||
expect(state.splitProposal?.commits[0]?.changes.map(change => change.path)).toContain(
|
||||
"packages/coding-agent/CHANGELOG.md",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user