Tucker McKnight <tmcknight@instructure.com> | Mon Feb 23 2026
[WIP] add tags to the Repository object Currently I'm just concatenating the tag results in the branchesWithHrefs object so that they show up in the branch list dropdown menu. Need to come up with something better here for showing them. Still needs code cleanup to DRY things up.
21 22 23 24 25 26
href: nav.repoBranchHome(branch.name) + '/' + data.nav.path,
date: repo.commits.get(branch.head).date.toISOString(),
}
})
return `
<!doctype html>21 22 23 24 25 26 27 28 29 30 31 32 33 34
href: nav.repoBranchHome(branch.name) + '/' + data.nav.path,
date: repo.commits.get(branch.head).date.toISOString(),
}
}).concat(repo.tags.map((tag) => {
return {
name: tag.name,
href: "tbd",
date: repo.commits.get(tag.sha).date.toISOString(),
}
}))
console.log(branchesWithHrefs)
return `
<!doctype html>77 78 79 80 81 82
eleventyConfig.addTemplateFormats("js")
const reposData = await repos(reposConfiguration, eleventyConfig.dir.output)
// TODO: make a better way of making this default to "" so that it doesn't have to
// be done again in src/repos.ts.
const reposPath = reposConfiguration.path || ""77 78 79 80 81 82 83
eleventyConfig.addTemplateFormats("js")
const slugify = eleventyConfig.getFilter("slugify")
const reposData = await repos(reposConfiguration, eleventyConfig.dir.output, slugify)
// TODO: make a better way of making this default to "" so that it doesn't have to
// be done again in src/repos.ts.
const reposPath = reposConfiguration.path || ""264 265 266 267 268 269
})
eleventyConfig.addAsyncFilter("getReadMe", async (repoName: string, branchName: string) => {
const location = getLocation(reposConfiguration, eleventyConfig.dir.output, repoName)
// TODO allow for other filenames besides README.md
const command = `git -C ${location} show ${branchName}:README.md`
try {264 265 266 267 268 269 270
})
eleventyConfig.addAsyncFilter("getReadMe", async (repoName: string, branchName: string) => {
const slugify = eleventyConfig.getFilter("slugify")
const location = getLocation(reposConfiguration, eleventyConfig.dir.output, repoName, slugify)
// TODO allow for other filenames besides README.md
const command = `git -C ${location} show ${branchName}:README.md`
try {134 135 136 137 138 139
"required": [
"location",
"defaultBranch",
"branches"
],
"type": "object"
},134 135 136 137 138 139 140
"required": [
"location",
"defaultBranch",
"branches",
"tags"
],
"type": "object"
},67 68 69 70 71 72 73
return hunks
}
const getLocation = (reposConfig: ReposConfiguration, outputDir: string, repoName: string): string => {
return outputDir + (reposConfig.path || "") + "/" + repoName + ".git"
}
export {67 68 69 70 71 72 73
return hunks
}
const getLocation = (reposConfig: ReposConfiguration, outputDir: string, repoName: string, slugify: Function): string => {
return outputDir + (reposConfig.path || "") + "/" + slugify(repoName) + ".git"
}
export {26 27 28 29 30
const cachedBranchNames = branchesForReposMap.get(repoName)
const cachedTagNames = tagsForReposMap.get(repoName)
if (cachedBranchNames !== undefined) {
return {branches: cachedBranchNames, tags: cachedTagNames}
}
26 27 28 29 30 31
const cachedBranchNames = branchesForReposMap.get(repoName)
const cachedTagNames = tagsForReposMap.get(repoName)
if (cachedBranchNames !== undefined) {
console.log({branches: cachedBranchNames, tags: cachedTagNames})
return {branches: cachedBranchNames, tags: cachedTagNames}
}
126 127 128 129 130
}).flat()
}).flat()
if (branchesForReposMap.get(repoName) === undefined) {
branchesForReposMap.set(repoName, branches)
}126 127 128 129 130 131 132
}).flat()
}).flat()
console.log(tags)
if (branchesForReposMap.get(repoName) === undefined) {
branchesForReposMap.set(repoName, branches)
}137 138 139 140 141 142 143 144 145 146 147 148 149
let cachedRepos: Array<Repository> | null = null
const repos: (reposConfig: ReposConfiguration, outputDir: string) => Promise<Array<Repository>> = async (reposConfig, outputDir) => {
if (cachedRepos !== null) { return cachedRepos }
const repoNames = Object.keys(reposConfig.repos)
cachedRepos = []
for (const repoName of repoNames) {
const repoLocation = getLocation(reposConfig, outputDir, repoName)
const commits: Repository['commits'] = new Map()
const branchesAndTags = await getBranchesAndTags(reposConfig.repos[repoName], repoName)
const branchNames = branchesAndTags.branches.map(branch => branch.name)137 138 139 140 141 142 143 144 145 146 147 148 149
let cachedRepos: Array<Repository> | null = null
const repos: (reposConfig: ReposConfiguration, outputDir: string, slugify: Function) => Promise<Array<Repository>> = async (reposConfig, outputDir, slugify) => {
if (cachedRepos !== null) { return cachedRepos }
const repoNames = Object.keys(reposConfig.repos)
cachedRepos = []
for (const repoName of repoNames) {
const repoLocation = getLocation(reposConfig, outputDir, repoName, slugify)
const commits: Repository['commits'] = new Map()
const branchesAndTags = await getBranchesAndTags(reposConfig.repos[repoName], repoName)
const branchNames = branchesAndTags.branches.map(branch => branch.name)153 154 155 156 157 158
}
const branches = await Promise.all(branchesAndTags.branches.map(async (branch) => {
const repoLocation = getLocation(reposConfig, outputDir, repoName)
const branchHeadRes = await exec(`git -C ${repoLocation} show-ref refs/heads/${branch.name}`)
const branchHead = branchHeadRes.stdout.split(" ")[0]
const result = {153 154 155 156 157 158
}
const branches = await Promise.all(branchesAndTags.branches.map(async (branch) => {
const repoLocation = getLocation(reposConfig, outputDir, repoName, slugify)
const branchHeadRes = await exec(`git -C ${repoLocation} show-ref refs/heads/${branch.name}`)
const branchHead = branchHeadRes.stdout.split(" ")[0]
const result = {167 168 169 170 171
return result
}))
const branchesWithCompareToInfo: Repository['branches'] = branches.map((branch) => {
const branchDescription = branchesAndTags.branches.find(branchToAdd => branchToAdd.name === branch.name)
const compareTo = branchDescription.compareTo || reposConfig.repos[repoName].defaultBranch167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
return result
}))
const tags = await Promise.all(branchesAndTags.tags.map(async (tag) => {
const repoLocation = getLocation(reposConfig, outputDir, repoName, slugify)
const tagHeadRes = await exec(`git -C ${repoLocation} show-ref refs/tags/${tag.name}`)
const tagHead = tagHeadRes.stdout.split(" ")[0]
const result = {
name: tag.name,
sha: tagHead,
fileList: await getFileList(tagHead, repoLocation)
}
return result
}))
const branchesWithCompareToInfo: Repository['branches'] = branches.map((branch) => {
const branchDescription = branchesAndTags.branches.find(branchToAdd => branchToAdd.name === branch.name)
const compareTo = branchDescription.compareTo || reposConfig.repos[repoName].defaultBranch210 211 212 213 214 215
branches: branchesWithCompareToInfo,
cloneUrl: cloneUrl.cloneUrl(reposConfig.baseUrl, repoName),
defaultBranch: reposConfig.repos[repoName].defaultBranch,
tags: [], // todo fill in tags, similar to branches
commits,
})
}210 211 212 213 214 215
branches: branchesWithCompareToInfo,
cloneUrl: cloneUrl.cloneUrl(reposConfig.baseUrl, repoName),
defaultBranch: reposConfig.repos[repoName].defaultBranch,
tags: tags,
commits,
})
}