Use the flatRels object on all templates

99f6343ce4b99c2c0a16a48e1836a823ee7036ed

Tucker McKnight <tmcknight@instructure.com> | Sun Apr 19 2026

Use the flatRels object on all templates

Fixes bugs with pages not getting generated for tags. Tag pages,
and having links properly point to them, seems to be working
in all places now.
js_templates/commits.ts:7
Before
6
7
8
9
10
11
12






13
14
15
  eleventyConfig: any,
  data: any,
) => {
  const pagesJustForRel = eleventyConfig.getFilter("pagesJustForRel")
  const slugify = eleventyConfig.getFilter("slugify")
  const date = eleventyConfig.getFilter("date")

⁣
⁣
⁣
⁣
⁣
⁣
  const nav = NavHelper(reposConfig, slugify, data.patchPage.repoName, data.patchPage.relName)

  const pageContent = [
    m('div', {class: "row mt-3 mb-1"},
After
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  eleventyConfig: any,
  data: any,
) => {
  const pagesJustForRef = eleventyConfig.getFilter("pagesJustForRef")
  const slugify = eleventyConfig.getFilter("slugify")
  const date = eleventyConfig.getFilter("date")

  const nav = NavHelper({
    reposConfig,
    slugify,
    currentRepoName: data.patchPage.repoName,
    currentRefName: data.patchPage.refName,
    currentRefType: data.patchPage.type,
  })

  const pageContent = [
    m('div', {class: "row mt-3 mb-1"},
js_templates/commits.ts:21
Before
20
21
22
23
24
25
          m('span', {class: "font-monospace me-2"}, data.patchPage.relName),
          m('a', {
            class: "btn btn-outline-primary badge shadow-none",
            href: nav.repoCurrentBranchRssFeed()
          }, [
            m('img', {
              src: `${nav.rootPath()}frontend/img/rss-icon.svg`,
After
20
21
22
23
24
25
          m('span', {class: "font-monospace me-2"}, data.patchPage.relName),
          m('a', {
            class: "btn btn-outline-primary badge shadow-none",
            href: nav.rssFeed()
          }, [
            m('img', {
              src: `${nav.rootPath()}frontend/img/rss-icon.svg`,
js_templates/commits.ts:34
Before
33
34
35
36
37
38
    ),
    m('nav', 
      m('ul', {class: "pagination"},
        pagesJustForRel(
          data.paginatedPatches,
          data.patchPage.repoName,
          data.patchPage.relName,
After
33
34
35
36
37
38
    ),
    m('nav', 
      m('ul', {class: "pagination"},
        pagesJustForRef(
          data.paginatedPatches,
          data.patchPage.repoName,
          data.patchPage.relName,
js_templates/commits.ts:68
Before
67
68
69
70
71
72
    })),
    m('nav',
      m('ul', {class: "pagination"},
        pagesJustForRel(
          data.paginatedPatches,
          data.patchPage.repoName,
          data.patchPage.relName,
After
67
68
69
70
71
72
    })),
    m('nav',
      m('ul', {class: "pagination"},
        pagesJustForRef(
          data.paginatedPatches,
          data.patchPage.repoName,
          data.patchPage.relName,
js_templates/common/htmlPage.ts:11
Before
10
11
12
13
14
15






16
17
18
19
20
21
22
23
24
25
26
27
28
29
  }

  const repo: Repository = data.currentRepo
  const rel: Repository['branches'][0] = data.currentRel

  const slugify = eleventyConfig.getFilter("slugify")
⁣
⁣
⁣
⁣
⁣
⁣
  const nav = NavHelper(reposConfig, slugify, repo.name, rel.name)

  const branchesWithHrefs = repo.branches.map((branch) => {
    return {
      name: branch.name,
      href: nav.repoBranchHome(branch.name) + '/' + data.nav.path,
      date: repo.commits.get(branch.sha).date.toISOString(),
    }
  }).concat(repo.tags.map((tag) => {
    return {
      name: tag.name,
      href: nav.repoTagHome(tag.name) + '/' + data.nav.path,
      date: repo.commits.get(tag.sha).date.toISOString(),
    }
  }))
After
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  }

  const repo: Repository = data.currentRepo
  const ref: Repository['branches'][0] = data.currentRef

  const slugify = eleventyConfig.getFilter("slugify")
  const nav = NavHelper({
    reposConfig,
    slugify,
    currentRepoName: repo.name,
    currentRefName: ref.name,
    currentRefType: data.currentRefType,
  })

  const branchesWithHrefs = repo.branches.map((branch) => {
    return {
      name: branch.name,
      href: nav.refHome({refName: branch.name, refType: 'branch'}) + '/' + data.nav.path,
      date: repo.commits.get(branch.sha).date.toISOString(),
    }
  }).concat(repo.tags.map((tag) => {
    return {
      name: tag.name,
      href: nav.refHome({refName: tag.name, refType: 'tag'}) + '/' + data.nav.path,
      date: repo.commits.get(tag.sha).date.toISOString(),
    }
  }))
js_templates/common/htmlPage.ts:37
Before
36
37
38
39
40
41
      m('script', m.trust(`
        window.branchesWithHrefs = ${JSON.stringify(branchesWithHrefs)};
        window.defaultBranch = "${repo.defaultBranch}";
        window.currentBranch = "${rel.name}";
        window.cloneUrl = "${repo.cloneUrl}";
      `)),
      m('link', {
After
36
37
38
39
40
41
      m('script', m.trust(`
        window.branchesWithHrefs = ${JSON.stringify(branchesWithHrefs)};
        window.defaultBranch = "${repo.defaultBranch}";
        window.currentBranch = "${ref.name}";
        window.cloneUrl = "${repo.cloneUrl}";
      `)),
      m('link', {
js_templates/common/htmlPage.ts:58
Before
57
58
59
60
61
62
        m('li', {class: "nav-item"},
          m('a', {
            class: "nav-link",
            href: nav.repoCurrentBranchHome()
          }, repo.name)
        ),
        m('li', {class: "nav-item"}, [
After
57
58
59
60
61
62
        m('li', {class: "nav-item"},
          m('a', {
            class: "nav-link",
            href: nav.refHome()
          }, repo.name)
        ),
        m('li', {class: "nav-item"}, [
js_templates/common/htmlPage.ts:69
Before
68
69
70
71
72
73
              'data-bs-toggle': "dropdown",
              'data-bs-auto-close': "outside",
              'aria-expanded': "false"
            }, rel.name),
            m('div', {class: "dropdown-menu"}, [
              m('form', {class: "mx-3 my-1"}, [
                m('input', {type: "text", class: "form-control", id: "dropdownBranchSearch", placeholder: "Search branches..."}),
After
68
69
70
71
72
73
              'data-bs-toggle': "dropdown",
              'data-bs-auto-close': "outside",
              'aria-expanded': "false"
            }, ref.name),
            m('div', {class: "dropdown-menu"}, [
              m('form', {class: "mx-3 my-1"}, [
                m('input', {type: "text", class: "form-control", id: "dropdownBranchSearch", placeholder: "Search branches..."}),
js_templates/common/htmlPage.ts:93
Before
92
93
94
95
96
97
              ]),
              m('div', {class: "dropdown-divider"}),
              m('div', {id: "dropdown-branches-results", class: "dropdown-branches"},
                branchesListItems(branchesWithHrefs, repo.defaultBranch, rel.name, 'date')
              )
            ])
          ])
After
92
93
94
95
96
97
              ]),
              m('div', {class: "dropdown-divider"}),
              m('div', {id: "dropdown-branches-results", class: "dropdown-branches"},
                branchesListItems(branchesWithHrefs, repo.defaultBranch, ref.name, 'date')
              )
            ])
          ])
js_templates/feed.ts:1
Before
0
1
2
3
4
5
import m from 'mithril'
import render from 'mithril-node-render'
import { type Repository } from '../src/dataTypes.ts'
import getFlatRels from '../src/flatRels.ts'
import { dateToRfc3339 } from '@11ty/eleventy-plugin-rss'
import flatPatches from '../src/flatPatches.ts'
After
0
1
2
3
4
5
import m from 'mithril'
import render from 'mithril-node-render'
import { type Repository } from '../src/dataTypes.ts'
import getFlatRefs from '../src/flatRefs.ts'
import { dateToRfc3339 } from '@11ty/eleventy-plugin-rss'
import flatPatches from '../src/flatPatches.ts'
js_templates/file.ts:15
Before
14
15
16
17
18
19
  const languageExtension = eleventyConfig.getFilter("languageExtension")
  const renderContentIfAvailable = eleventyConfig.getFilter("renderContentIfAvailable")

  const currentRel: Branch = data.currentRel
  const fileInfo: FlatFileEntry = data.fileInfo

  const pageContent = [  
After
14
15
16
17
18
19
  const languageExtension = eleventyConfig.getFilter("languageExtension")
  const renderContentIfAvailable = eleventyConfig.getFilter("renderContentIfAvailable")

  const currentRef: Branch = data.currentRef
  const fileInfo: FlatFileEntry = data.fileInfo

  const pageContent = [  
js_templates/file.ts:96
Before
95
96
97
98
99
100
            m('div', {class: "row rendered-content"},
              m('div', {class: "col"},
                m.trust(await renderContentIfAvailable(
                  currentRel.fileList.get(fileInfo.file).fileInfo.contents
                ))
              )
            )
After
95
96
97
98
99
100
            m('div', {class: "row rendered-content"},
              m('div', {class: "col"},
                m.trust(await renderContentIfAvailable(
                  currentRef.fileList.get(fileInfo.file).fileInfo.contents
                ))
              )
            )
js_templates/file.ts:116
Before
115
116
117
118
119
120
              m('div', {class: "col-auto p-0"},
                m('code', {style: "white-space: pre;"},
                  m('pre', {class: "language-text"},
                    lineNumbers(currentRel.fileList.get(fileInfo.file).fileInfo.contents).map((lineNumber) => {
                      return lineNumber
                    }).join('\n')
                  )
After
115
116
117
118
119
120
              m('div', {class: "col-auto p-0"},
                m('code', {style: "white-space: pre;"},
                  m('pre', {class: "language-text"},
                    lineNumbers(currentRef.fileList.get(fileInfo.file).fileInfo.contents).map((lineNumber) => {
                      return lineNumber
                    }).join('\n')
                  )
js_templates/file.ts:125
Before
124
125
126
127
128
129
130
131
132
133
134
135
136
              m('div', {id: "annotations", class: "col-auto d-none p-0"},
                m('code', {style: "white-space: pre;"}, [
                  m('pre', {class: "language-text"}, m.trust(
                    currentRel.fileList.get(fileInfo.file).fileInfo.blameLines.map((annotation) => {
                      return `<a href="${data.reposPath}/${slugify(fileInfo.repoName)}/branch/${slugify(fileInfo.branchName)}/commits/${annotation.sha}">${annotation.sha.substr(0, 6)}</a> ${annotation.author}`
                    }).join('\n')))
                ])
              ),
              m('div', {class: "col overflow-scroll p-0"},
                m('code', m.trust(highlightCode(
                  currentRel.fileList.get(fileInfo.file).fileInfo.contents,
                  languageExtension(
                    fileInfo.file,
                    fileInfo.repoName
After
124
125
126
127
128
129
130
131
132
133
134
135
136
              m('div', {id: "annotations", class: "col-auto d-none p-0"},
                m('code', {style: "white-space: pre;"}, [
                  m('pre', {class: "language-text"}, m.trust(
                    currentRef.fileList.get(fileInfo.file).fileInfo.blameLines.map((annotation) => {
                      return `<a href="${data.reposPath}/${slugify(fileInfo.repoName)}/branch/${slugify(fileInfo.branchName)}/commits/${annotation.sha}">${annotation.sha.substr(0, 6)}</a> ${annotation.author}`
                    }).join('\n')))
                ])
              ),
              m('div', {class: "col overflow-scroll p-0"},
                m('code', m.trust(highlightCode(
                  currentRef.fileList.get(fileInfo.file).fileInfo.contents,
                  languageExtension(
                    fileInfo.file,
                    fileInfo.repoName
js_templates/files.ts:3
Before
2
3
4
5
6
7
import htmlPage from './common/htmlPage.ts'

export default async (reposConfig: any, eleventyConfig: any, data: any) => {
  const branch: Repository['branches'][0] = data.currentRel
  const topLevelFilesOnly = eleventyConfig.getFilter("topLevelFilesOnly")
  const slugify = eleventyConfig.getFilter("slugify")
After
2
3
4
5
6
7
import htmlPage from './common/htmlPage.ts'

export default async (reposConfig: any, eleventyConfig: any, data: any) => {
  const branch: Repository['branches'][0] = data.currentRef
  const topLevelFilesOnly = eleventyConfig.getFilter("topLevelFilesOnly")
  const slugify = eleventyConfig.getFilter("slugify")
js_templates/files.ts:14
Before
13
14
15
16
17
18
      m('div', {class: "col"},
        m('p', [
          'Files snapshot from ',
          m('span', {class: "font-monospace"}, data.flatRel.relName)
        ])
      )
    ]),
After
13
14
15
16
17
18
      m('div', {class: "col"},
        m('p', [
          'Files snapshot from ',
          m('span', {class: "font-monospace"}, data.flatRef.relName)
        ])
      )
    ]),
js_templates/files.ts:27
Before
26
27
28
29
30
31
      return m('li', {class: 'list-group-item'}, [
        file.isDirectory ? m.trust('<span>&#x1F4C1;&nbsp;</span>') : null,
        m('a', {
          href: `${data.reposPath}/${slugify(data.flatRel.repoName)}/branch/${slugify(data.flatRel.relName)}/files/${
            file.fullPath.split('/')
            .map((pathPart) => {
              return pathPart.split('.').map((subPart) => {
After
26
27
28
29
30
31
      return m('li', {class: 'list-group-item'}, [
        file.isDirectory ? m.trust('<span>&#x1F4C1;&nbsp;</span>') : null,
        m('a', {
          href: `${data.reposPath}/${slugify(data.flatRef.repoName)}/branch/${slugify(data.flatRef.relName)}/files/${
            file.fullPath.split('/')
            .map((pathPart) => {
              return pathPart.split('.').map((subPart) => {
js_templates/raw.ts:3
Before
2
3
4
5
6
7

export default async (eleventyConfig: any) => {
  return async (data) => {
    const branch: Branch = data.currentRel

    return branch.fileList.get(data.fileInfo.file).fileInfo.contents
  }
After
2
3
4
5
6
7

export default async (eleventyConfig: any) => {
  return async (data) => {
    const branch: Branch = data.currentRef

    return branch.fileList.get(data.fileInfo.file).fileInfo.contents
  }
js_templates/repo.ts:31
Before
30
31
32
33
34
35

  // todo: this is probably broken for repos that use fewer than 6 languages
  let languagePercentages: Array<[string, number]> = []
  const total = Array.from(rel.fileList.keys()).length

  for (const entry of languageCounts) {
    languagePercentages.push([entry[0], entry[1] / total])
After
30
31
32
33
34
35

  // todo: this is probably broken for repos that use fewer than 6 languages
  let languagePercentages: Array<[string, number]> = []
  const total = Array.from(ref.fileList.keys()).length

  for (const entry of languageCounts) {
    languagePercentages.push([entry[0], entry[1] / total])
js_templates/repo.ts:46
Before
45
46
47
48
49
50

  const largestPercent = Math.max(...topLanguagePercentages.map(tuple => tuple[1]), otherLanguagePercent)

  const readmeContent = await renderContentIfAvailable(await getReadMe(repo.name, rel.name), rel.name)

  const pageContent = [
    m('div', {class: "row"}, [
After
45
46
47
48
49
50

  const largestPercent = Math.max(...topLanguagePercentages.map(tuple => tuple[1]), otherLanguagePercent)

  const readmeContent = await renderContentIfAvailable(await getReadMe(repo.name, ref.name), ref.name)

  const pageContent = [
    m('div', {class: "row"}, [
js_templates/repo.ts:103
Before
102
103
104
105
106
107
108
109
110
111
112
          m('div', {class: "row mt-2"}, [
            m('div', {class: "col"}, [
              m('p', {class: "font-monospace text-white mb-2 d-inline-block"}, [
                m('a', {class: "btn btn-outline-info badge shadow-none me-2", href: nav.repoCurrentBranchRssFeed()}, [
                  m('img', {src: `${nav.rootPath()}frontend/img/rss-icon.svg`, style: "width: 11px; margin-right: 5px;"}),
                  'RSS'
                ]),
                `Latest commit: ${latestCommit.date.toDateString()} `,
                m('a', {class: "fw-bold link-info", href: `${nav.repoBranchCommitsBase()}${latestCommit.hash}`}, latestCommit.hash.substr(0, 6)),
                ' ',
                latestCommitMessage,
              ])
After
102
103
104
105
106
107
108
109
110
111
112
          m('div', {class: "row mt-2"}, [
            m('div', {class: "col"}, [
              m('p', {class: "font-monospace text-white mb-2 d-inline-block"}, [
                m('a', {class: "btn btn-outline-info badge shadow-none me-2", href: nav.rssFeed()}, [
                  m('img', {src: `${nav.rootPath()}frontend/img/rss-icon.svg`, style: "width: 11px; margin-right: 5px;"}),
                  'RSS'
                ]),
                `Latest commit: ${latestCommit.date.toDateString()} `,
                m('a', {class: "fw-bold link-info", href: `${nav.commit(latestCommit.hash)}`}, latestCommit.hash.substr(0, 6)),
                ' ',
                latestCommitMessage,
              ])
js_templates/tags.ts:8
Before
7
8
9






10
11
12
13
14
15
16
17
18
19
20
21
22
23
  data: any,
) => {
  const slugify = eleventyConfig.getFilter("slugify")
⁣
⁣
⁣
⁣
⁣
⁣
  const nav = NavHelper(reposConfig, slugify, data.flatRel.repoName, data.flatRel.relName)

  const tags = data.flatRels.filter(rel => rel.type === "tag")

  const branchCards = (tags) => {
    return m('ul', tags.map((tag) => {
      return tag.repoName === data.flatRel.repoName ?
        m('li', [
          m('a', {
            href: `${data.reposPath}/${slugify(tag.repoName)}/tag/${slugify(tag.relName)}/tags`
          }, tag.relName),
          tag.relName === data.flatRel.relName
            ? m('div', {class: "badge rounded-pill bg-secondary mx-1"}, 'current') : null,
          m('ul', [
            tag.description ? m('li', tag.description) : null
After
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  data: any,
) => {
  const slugify = eleventyConfig.getFilter("slugify")
  const nav = NavHelper({
    reposConfig,
    slugify,
    currentRepoName: data.flatRef.repoName,
    currentRefName: data.flatRef.refName,
    currentRefType: data.flatRef.refType,
  })

  const tags = data.flatRefs.filter(ref => ref.type === "tag")

  const branchCards = (tags) => {
    return m('ul', tags.map((tag) => {
      return tag.repoName === data.flatRef.repoName ?
        m('li', [
          m('a', {
            href: `${data.reposPath}/${slugify(tag.repoName)}/tag/${slugify(tag.refName)}/tags`
          }, tag.refName),
          tag.refName === data.flatRef.refName
            ? m('div', {class: "badge rounded-pill bg-secondary mx-1"}, 'current') : null,
          m('ul', [
            tag.description ? m('li', tag.description) : null
main.ts:2
Before
1
2
3
4
5
6
import util from 'util'
import childProcess from 'child_process'
import {repos, getBranchesAndTags} from './src/repos.ts'
import getFlatRels from './src/flatRels.ts'
import flatFiles from './src/flatFiles.ts'
import flatPatches from './src/flatPatches.ts'
import paginatedPatches, {type PatchPage} from './src/paginatedPatches.ts'
After
1
2
3
4
5
6
import util from 'util'
import childProcess from 'child_process'
import {repos, getBranchesAndTags} from './src/repos.ts'
import getFlatRefs from './src/flatRefs.ts'
import flatFiles from './src/flatFiles.ts'
import flatPatches from './src/flatPatches.ts'
import paginatedPatches, {type PatchPage} from './src/paginatedPatches.ts'
main.ts:89
Before
88
89
90
91
92
93
94
  eleventyConfig.addGlobalData("reposConfig", reposConfiguration)
  eleventyConfig.addGlobalData("reposPath", reposPath)

  const flatRels = getFlatRels(reposData)
  eleventyConfig.addGlobalData("flatRels", flatRels)

  eleventyConfig.addFilter("getFileName", (filePath: string) => {
    const pathParts = filePath.split("/")
After
88
89
90
91
92
93
94
  eleventyConfig.addGlobalData("reposConfig", reposConfiguration)
  eleventyConfig.addGlobalData("reposPath", reposPath)

  const flatRefs = getFlatRefs(reposData)
  eleventyConfig.addGlobalData("flatRefs", flatRefs)

  eleventyConfig.addFilter("getFileName", (filePath: string) => {
    const pathParts = filePath.split("/")
main.ts:254
Before
253
254
255
256
257
258
259
    return isDirectory
  })

  eleventyConfig.addFilter("pagesJustForRel", (pages: Array<PatchPage>, repoName: string, relName: string, relType: "branch" | "tag") => {
    return pages.filter(page => page.repoName === repoName && page.relName === relName && page.type === relType)
  })

  eleventyConfig.addFilter("date", (dateString: string) => {
After
253
254
255
256
257
258
259
    return isDirectory
  })

  eleventyConfig.addFilter("pagesJustForRef", (pages: Array<PatchPage>, repoName: string, refName: string, refType: "branch" | "tag") => {
    return pages.filter(page => page.repoName === repoName && page.refName === refName && page.type === refType)
  })

  eleventyConfig.addFilter("date", (dateString: string) => {
main.ts:296
Before
After
main.ts:335
Before
After
main.ts:383
Before
382
383
384
385
386
387
388
      permalink: (data) => {
        const repoName = data.fileInfo.repoName
        const branchName = data.fileInfo.branchName
        const relType = data.fileInfo.type
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/${relType}/${eleventyConfig.getFilter("slugify")(branchName)}/files/${data.fileInfo.file.split('/').map((filePart) => filePart.split('.').map((subPart) => eleventyConfig.getFilter("slugify")(subPart)).join('.')).join('/')}.html`
      },
      eleventyComputed: {
        nav: {
After
382
383
384
385
386
387
388
      permalink: (data) => {
        const repoName = data.fileInfo.repoName
        const branchName = data.fileInfo.branchName
        const refType = data.fileInfo.type
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/${refType}/${eleventyConfig.getFilter("slugify")(branchName)}/files/${data.fileInfo.file.split('/').map((filePart) => filePart.split('.').map((subPart) => eleventyConfig.getFilter("slugify")(subPart)).join('.')).join('/')}.html`
      },
      eleventyComputed: {
        nav: {
main.ts:395
Before
394
395
396
397
398
399
400
401

402
403
        currentRepo: (data) => reposData.find(repo => {
          return repo.name === data.fileInfo.repoName
        }),
        currentRel: (data) => reposData.find(repo => {
          return repo.name === data.fileInfo.repoName
        }).branches.find(branch => {
          return branch.name === data.fileInfo.branchName
        }),
⁣
      },
      navTab: "files",
    }
After
394
395
396
397
398
399
400
401
402
403
404
        currentRepo: (data) => reposData.find(repo => {
          return repo.name === data.fileInfo.repoName
        }),
        currentRef: (data) => reposData.find(repo => {
          return repo.name === data.fileInfo.repoName
        }).branches.find(branch => {
          return branch.name === data.fileInfo.branchName
        }),
        currentRefType: (data) => data.fileInfo.refType,
      },
      navTab: "files",
    }
main.ts:420
Before
419
420
421
422
423
424
425
426
427
428
429
430

431
432
      permalink: (data) => {
        const repoName = data.fileInfo.repoName
        const branchName = data.fileInfo.branchName
        const relType = data.fileInfo.type
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/${relType}/${eleventyConfig.getFilter("slugify")(branchName)}/raw/${data.fileInfo.file.split('.').map(filePart => eleventyConfig.getFilter("slugify")(filePart)).join('.')}`
      },
      eleventyComputed: {
        currentRel: (data) => reposData.find(repo => {
          return repo.name === data.fileInfo.repoName
        }).branches.find(branch => {
          return branch.name === data.fileInfo.branchName
        }),
⁣
      }
    }
  )
After
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
      permalink: (data) => {
        const repoName = data.fileInfo.repoName
        const branchName = data.fileInfo.branchName
        const refType = data.fileInfo.type
        return `${reposPath}/${eleventyConfig.getFilter("slugify")(repoName)}/${refType}/${eleventyConfig.getFilter("slugify")(branchName)}/raw/${data.fileInfo.file.split('.').map(filePart => eleventyConfig.getFilter("slugify")(filePart)).join('.')}`
      },
      eleventyComputed: {
        currentRef: (data) => reposData.find(repo => {
          return repo.name === data.fileInfo.repoName
        }).branches.find(branch => {
          return branch.name === data.fileInfo.branchName
        }),
        currentRefType: (data) => data.fileInfo.refType,
      }
    }
  )
main.ts:439
Before
After
main.ts:477
Before
After
main.ts:523
Before
After
main.ts:563
Before
After
main.ts:595
Before
After
src/__tests__/helpers.test.js:0
Before






⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
After
-1
0
1
2
3
4
5
6
import { expect, test } from 'vitest'
import { getGitDiffsFromPatchText } from '../../dist/src/helpers.js'
import { singleCommit, largerCommit } from './fixtures/patches.js'

test("asdf", () => {
  const result = getGitDiffsFromPatchText(largerCommit)
  console.log(result[0])
  expect(true).toBe(true)
})
src/dataTypes.ts.orig:1
Before
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export type Repository = {
  name: string,
  description?: string,
  cloneUrl: string,
  defaultBranch: string,
  branches: Array<{
    name: string,
    head: string,
    fileList: Array<string>,
  }>,
  tags?: Array<{
    name: string,
    sha: string,
    fileList: Array<string>,
  }>,
<<<<<<< HEAD
  commits: Map<string, {
    hash: string,
=======
  commits?: Map<string, {
>>>>>>> 359136b (allow commit references to be null, e.g. for the first commit which has no parent)
    message: string,
    author: string,
    date: Date,
    parent: string | null,
    diffs: Array<{
      fileName: string,
      lineNumber: number,
      beforeText: string,
      afterText: string,
    }>
  }>,
}
After






























⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
⁣
src/flatPatches.ts:3
Before
2
3
4
5
6
7
type FlatPatchRecord = {
  commit: ReturnType<Repository['commits']['get']>,
  repoName: string,
  relName: string,
  type: "branch" | "tag",
}
After
2
3
4
5
6
7
type FlatPatchRecord = {
  commit: ReturnType<Repository['commits']['get']>,
  repoName: string,
  refName: string,
  type: "branch" | "tag",
}
src/flatPatches.ts:23
Before
22
23
24
25
26
27
          type: "branch",
          commit: currentCommit,
          repoName: repo.name,
          relName: branch.name
        })

        currentCommit = repo.commits.get(currentCommit.parent)
After
22
23
24
25
26
27
          type: "branch",
          commit: currentCommit,
          repoName: repo.name,
          refName: branch.name
        })

        currentCommit = repo.commits.get(currentCommit.parent)
src/flatPatches.ts:40
Before
39
40
41
42
43
44
          type: "tag",
          commit: currentCommit,
          repoName: repo.name,
          relName: tag.name,
        })

        currentCommit = repo.commits.get(currentCommit.parent)
After
39
40
41
42
43
44
          type: "tag",
          commit: currentCommit,
          repoName: repo.name,
          refName: tag.name,
        })

        currentCommit = repo.commits.get(currentCommit.parent)
src/flatRels.ts:1
Before
0
1
2
3
4
5
import { type Repository } from "./dataTypes.ts"

type BranchEntry = {
  relName: string,
  type: "branch",
  repoName: string,
  compareTo: string,
After
0
1
2
3
4
5
import { type Repository } from "./dataTypes.ts"

type BranchEntry = {
  refName: string,
  type: "branch",
  repoName: string,
  compareTo: string,
src/flatRels.ts:10
Before
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
}

type TagEntry = {
  relName: string,
  type: "tag",
  repoName: string,
}

let cachedRels: Array<BranchEntry | TagEntry> | null = null

export default (repos: Array<Repository>) => {
  if (cachedRels !== null) { return cachedRels }

  cachedRels = repos.flatMap((repo) => {
    const branches: Array<BranchEntry> = repo.branches.map((branch) => {
      const result: BranchEntry = {
        relName: branch.name,
        type: "branch",
        repoName: repo.name,
        compareTo: branch.compareTo,
After
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
}

type TagEntry = {
  refName: string,
  type: "tag",
  repoName: string,
}

let cachedRefs: Array<BranchEntry | TagEntry> | null = null

export default (repos: Array<Repository>) => {
  if (cachedRefs !== null) { return cachedRefs }

  cachedRefs = repos.flatMap((repo) => {
    const branches: Array<BranchEntry> = repo.branches.map((branch) => {
      const result: BranchEntry = {
        refName: branch.name,
        type: "branch",
        repoName: repo.name,
        compareTo: branch.compareTo,
src/flatRels.ts:35
Before
34
35
36
37
38
39
    })
    const tags: Array<TagEntry> = repo.tags.map((tag) => {
      return {
        relName: tag.name,
        type: "tag",
        repoName: repo.name,
      }
After
34
35
36
37
38
39
    })
    const tags: Array<TagEntry> = repo.tags.map((tag) => {
      return {
        refName: tag.name,
        type: "tag",
        repoName: repo.name,
      }
src/flatRels.ts:44
Before
43
44
45
46
    return [...branches, ...tags]
  })

  return cachedRels
}
After
43
44
45
46
    return [...branches, ...tags]
  })

  return cachedRefs
}
src/paginatedPatches.ts:3
Before
2
3
4
5
6
7

export type PatchPage = {
  repoName: string,
  relName: string,
  type: "branch" | "tag",
  commits: Array<ReturnType<Repository['commits']['get']>>,
  pageNumber: number,
After
2
3
4
5
6
7

export type PatchPage = {
  repoName: string,
  refName: string,
  type: "branch" | "tag",
  commits: Array<ReturnType<Repository['commits']['get']>>,
  pageNumber: number,
src/paginatedPatches.ts:22
Before
21
22
23
24
25
26
    const index = paginatedPatches.findIndex((page) => {
      return (
        page.repoName === patch.repoName
        && page.relName == patch.relName
        && page.type == patch.type
        && page.commits.length <= patchesPerPage
      )
After
21
22
23
24
25
26
    const index = paginatedPatches.findIndex((page) => {
      return (
        page.repoName === patch.repoName
        && page.refName == patch.refName
        && page.type == patch.type
        && page.commits.length <= patchesPerPage
      )
src/paginatedPatches.ts:31
Before
30
31
32
33
34
35
36
37
38
39
40
    if (index === -1) {
      const pageNumber = paginatedPatches.filter(page => (
        page.repoName === patch.repoName
        && page.relName === patch.relName
        && page.type === patch.type
      )).length + 1
      paginatedPatches.push({
        repoName: patch.repoName,
        relName: patch.relName,
        commits: [patch.commit],
        type: patch.type,
        // current page number is one more than "how many items in paginatedPatches already
After
30
31
32
33
34
35
36
37
38
39
40
    if (index === -1) {
      const pageNumber = paginatedPatches.filter(page => (
        page.repoName === patch.repoName
        && page.refName === patch.refName
        && page.type === patch.type
      )).length + 1
      paginatedPatches.push({
        repoName: patch.repoName,
        refName: patch.refName,
        commits: [patch.commit],
        type: patch.type,
        // current page number is one more than "how many items in paginatedPatches already
src/repos.ts:27
Before
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}
  }
After
26
27
28

29
30
  const cachedBranchNames = branchesForReposMap.get(repoName)
  const cachedTagNames = tagsForReposMap.get(repoName)
  if (cachedBranchNames !== undefined) {
⁣
    return {branches: cachedBranchNames, tags: cachedTagNames}
  }
src/repos.ts:128
Before
127
128
129
130
131
132
133
    }).flat()
  }).flat()

  console.log(tags)

  if (branchesForReposMap.get(repoName) === undefined) {
    branchesForReposMap.set(repoName, branches)
  }
After
127
128
129


130
131
    }).flat()
  }).flat()

⁣
⁣
  if (branchesForReposMap.get(repoName) === undefined) {
    branchesForReposMap.set(repoName, branches)
  }