[WIP] add tags to the Repository object

9aaaea2a8eadd4715acbcd2b261b1dc3114f0293

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.
js_templates/common/htmlPage.ts:22
Before
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>
After
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>
main.ts:78
Before
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 || ""
After
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 || ""
main.ts:265
Before
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 {
After
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 {
schemas/ReposConfiguration.json:135
Before
134
135
136
137

138
139
      "required": [
        "location",
        "defaultBranch",
        "branches"
⁣
      ],
      "type": "object"
    },
After
134
135
136
137
138
139
140
      "required": [
        "location",
        "defaultBranch",
        "branches",
        "tags"
      ],
      "type": "object"
    },
src/helpers.ts:68
Before
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 {
After
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 {
src/repos.ts:27
Before
26
27
28

29
30
  const cachedBranchNames = branchesForReposMap.get(repoName)
  const cachedTagNames = tagsForReposMap.get(repoName)
  if (cachedBranchNames !== undefined) {
⁣
    return {branches: cachedBranchNames, tags: cachedTagNames}
  }
After
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}
  }
src/repos.ts:127
Before
126
127
128


129
130
    }).flat()
  }).flat()

⁣
⁣
  if (branchesForReposMap.get(repoName) === undefined) {
    branchesForReposMap.set(repoName, branches)
  }
After
126
127
128
129
130
131
132
    }).flat()
  }).flat()

  console.log(tags)

  if (branchesForReposMap.get(repoName) === undefined) {
    branchesForReposMap.set(repoName, branches)
  }
src/repos.ts:138
Before
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)
After
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)
src/repos.ts:154
Before
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 = {
After
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 = {
src/repos.ts:168
Before
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].defaultBranch
After
167
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].defaultBranch
src/repos.ts:211
Before
210
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,
    })
  }
After
210
211
212
213
214
215
      branches: branchesWithCompareToInfo,
      cloneUrl: cloneUrl.cloneUrl(reposConfig.baseUrl, repoName),
      defaultBranch: reposConfig.repos[repoName].defaultBranch,
      tags: tags,
      commits,
    })
  }