Skip to content

Commit ea426bb

Browse files
critesjoshclaude
andcommitted
feat: pull aztec-packages docs from next branch via sparsePathOverrides
Add sparsePathOverrides to RepoConfig so specific sparse paths can be checked out from a different branch after the tag-based clone. This keeps docs/docs on the latest next branch while other paths stay pinned to the version tag. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 131afd9 commit ea426bb

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

src/repos/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export interface RepoConfig {
2222
code?: string[];
2323
docs?: string[];
2424
};
25+
/** Override specific sparse paths to come from a different branch instead of the tag */
26+
sparsePathOverrides?: { paths: string[]; branch: string }[];
2527
}
2628

2729
/** Default Aztec version (tag) to use - can be overridden via AZTEC_DEFAULT_VERSION env var */
@@ -43,6 +45,9 @@ const BASE_REPOS: Omit<RepoConfig, "tag">[] = [
4345
"boxes",
4446
"playground",
4547
],
48+
sparsePathOverrides: [
49+
{ paths: ["docs/docs"], branch: "next" },
50+
],
4651
description: "Main Aztec monorepo - documentation, aztec-nr framework, and reference contracts",
4752
searchPatterns: {
4853
code: ["*.nr", "*.ts"],

src/utils/git.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ export async function cloneRepo(
9090
await repoGit.raw(["sparse-checkout", "set", ...config.sparse]);
9191
await repoGit.fetch(["--depth=1", "origin", `refs/tags/${config.tag}:refs/tags/${config.tag}`]);
9292
await repoGit.checkout(config.tag);
93+
94+
// Apply sparse path overrides from different branches
95+
if (config.sparsePathOverrides) {
96+
for (const override of config.sparsePathOverrides) {
97+
await repoGit.fetch(["--depth=1", "origin", override.branch]);
98+
await repoGit.checkout([`origin/${override.branch}`, "--", ...override.paths]);
99+
}
100+
}
93101
} else {
94102
await git.clone(config.url, repoPath, [
95103
"--filter=blob:none",

tests/repos/config.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ describe("AZTEC_REPOS", () => {
2626
expect(noir!.sparse!.length).toBeGreaterThan(0);
2727
});
2828

29+
it("aztec-packages has sparsePathOverrides for docs/docs on next branch", () => {
30+
const ap = AZTEC_REPOS.find((r) => r.name === "aztec-packages");
31+
expect(ap?.sparse).toContain("docs/docs");
32+
expect(ap?.sparsePathOverrides).toEqual([
33+
{ paths: ["docs/docs"], branch: "next" },
34+
]);
35+
});
36+
2937
it('noir and noir-examples have branch: "master"', () => {
3038
const noir = AZTEC_REPOS.find((r) => r.name === "noir");
3139
const noirExamples = AZTEC_REPOS.find((r) => r.name === "noir-examples");

tests/utils/git.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,36 @@ describe("cloneRepo", () => {
146146
expect(mockGitInstance.checkout).toHaveBeenCalledWith("v1.0.0");
147147
});
148148

149+
it("sparse + tag + sparsePathOverrides: fetches override branch and checks out paths", async () => {
150+
const overrideConfig: RepoConfig = {
151+
...sparseConfig,
152+
sparsePathOverrides: [{ paths: ["docs/docs"], branch: "next" }],
153+
};
154+
mockExistsSync.mockReturnValue(false);
155+
mockGitInstance.clone.mockResolvedValue(undefined);
156+
mockGitInstance.raw.mockResolvedValue(undefined);
157+
mockGitInstance.fetch.mockResolvedValue(undefined);
158+
mockGitInstance.checkout.mockResolvedValue(undefined);
159+
160+
const result = await cloneRepo(overrideConfig);
161+
expect(result).toContain("Cloned aztec-packages");
162+
163+
// Normal tag checkout happens first
164+
expect(mockGitInstance.checkout).toHaveBeenCalledWith("v1.0.0");
165+
166+
// Then override: fetch the branch and checkout paths from it
167+
expect(mockGitInstance.fetch).toHaveBeenCalledWith([
168+
"--depth=1",
169+
"origin",
170+
"next",
171+
]);
172+
expect(mockGitInstance.checkout).toHaveBeenCalledWith([
173+
"origin/next",
174+
"--",
175+
"docs/docs",
176+
]);
177+
});
178+
149179
it("sparse + commit: clones with sparse flags, fetches commit", async () => {
150180
const commitConfig: RepoConfig = {
151181
...sparseConfig,

0 commit comments

Comments
 (0)