Sun Dec 07 2025
Tucker McKnight <tucker@pangolin.lan>
Use the git -C flag instead of changing directories For some reason, when trying to generate the site in a git post-receive hook, the `cd` command doesn't seem to be working. Let's try it with git's built-in -C flag instead, which allows you to specify the location of the git repo without actually cd-ing into that directory.
c945a92bbe22b7562626d9667dd71b6050b79279
3
const rootPath = `${reposPath}/${slugify(repoName)}/branches`
3
4
5
6
7
8
9
10
11
// These two aren't actually used by any pages, but they're in almost
// every page URL. E.g. all of them start with 'repos/my-repo-name'
// or 'repos/my-repo-name/branches.'
const repoBasePath = `${reposPath}/${slugify(repoName)}`
const rootBasePathBranches = `${repoBasePath}/branches`
const currentBranchPath = `${rootBasePathBranches}/${slugify(branchName)}`
15
16
17
18
19
return `${rootPath}/${slugify(reposConfig.repos[repoName].defaultBranch)}`
repoCurrentBranchHome: () => rootPath,
return `${rootPath}/files`
repoCurrentBranchCommits: () => `${rootPath}/commits`,
repoCurrentBranchBranches: () => `${rootPath}/branches`,
15
16
17
18
19
20
21
return `${rootBasePathBranches}/${slugify(reposConfig.repos[repoName].defaultBranch)}`
},
repoCurrentBranchHome: () => {
return currentBranchPath
return `${currentBranchPath}/files`
repoCurrentBranchCommits: () => `${currentBranchPath}/commits`,
repoCurrentBranchBranches: () => `${currentBranchPath}/branches`,
66
67
68
69
const fetchCommands = repoConfig.branchesToPull.map(branch => `git fetch origin ${branch}:${branch}`).join('; ')
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && ${fetchCommands}; git update-server-info)`)
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/"} && git clone ${originalLocation} ${gitRepoName} --bare)`)
await exec(`(cd ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} && git update-server-info)`)
66
67
68
69
70
const location = eleventyConfig.dir.output + reposPath + "/" + gitRepoName
const fetchCommands = repoConfig.branchesToPull.map(branch => `git -C ${location} fetch origin ${branch}:${branch}`).join('; ')
await exec(`${fetchCommands} && git update-server-info`)
await exec(`git clone ${originalLocation} ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} --bare`)
await exec(`git -C ${eleventyConfig.dir.output + reposPath + "/" + gitRepoName} update-server-info`)
84
await exec(`(cd ${tempDirRepoPath} && git checkout ${branch})`)
84
await exec(`git -C ${tempDirRepoPath} checkout ${branch}`)
95
95
96
97
const location = eleventyConfig.dir.output + reposPath + "/" + gitRepoName
await exec(`git -C ${location} symbolic-ref HEAD refs/heads/${repoConfig.defaultBranch}`)
203
204
const command = `git show ${branch}:${filename}`
const res = await exec(`(cd ${location} && ${command})`)
203
204
const command = `git -C ${location} show ${branch}:${filename}`
const res = await exec(command)
222
223
const command = `git show ${branchName}:README.md`
const res = await exec(`(cd ${location} && ${command})`)
222
223
const command = `git -C ${location} show ${branchName}:README.md`
const res = await exec(command)
42
const branchHeadRes = await exec(`(cd ${repoLocation} && git show-ref --branch ${branchName})`)
42
const branchHeadRes = await exec(`git -C ${repoLocation} show-ref --branch ${branchName}`)
5
6
const command = `git ls-tree -r --name-only ${branchName}`
const result = await exec(`(cd ${repoLocation} && ${command})`)
5
6
const command = `git -C ${repoLocation} ls-tree -r --name-only ${branchName}`
const result = await exec(command)
39
40
const totalPatchesCountRes = await exec(`(cd ${repoLocation} && git rev-list --count ${branchName})`)
const gitLogSubsetRes = await exec(`(cd ${repoLocation} && git log ${branchName} -p -n 10 --skip ${i})`)
39
40
const totalPatchesCountRes = await exec(`git -C ${repoLocation} rev-list --count ${branchName}`)
const gitLogSubsetRes = await exec(`git -C ${repoLocation} log ${branchName} -p -n 10 --skip ${i}`)
99
100
const command = `git blame --porcelain ${branch} ${filename}`
const res = await exec(`(cd ${repoLocation} && ${command})`)
99
100
const command = `git -C ${repoLocation} blame --porcelain ${branch} ${filename}`
const res = await exec(command)