[WIP] get pages un-broken and loading

e3012a590b2a16944db35cbdd14fa48a19490f22

Tucker McKnight <tucker@pangolin.lan> | Sun Feb 22 2026

[WIP] get pages un-broken and loading

Needs code cleanup here. Tags are not displayed, but pages
that expected to have branches available to them now have branches
available.
README.md:35
Before
35
+         branchesToPull: ['main', 'develop', 'release/**'],
After
35
+         branches: ['main', 'develop', 'release/**'],
main.ts:1
Before
1
import {repos, getBranchNames} from './src/repos.ts'
After
1
import {repos, getBranchesAndTags} from './src/repos.ts'
main.ts:26
Before
26
export function beforeHook(eleventyConfig, reposConfiguration) {
After
26
export function beforeHook(eleventyConfig: any, reposConfiguration: ReposConfiguration) {
  const validator = ajv.compile(ConfigSchema)
  const valid = validator(reposConfiguration)
  if (!valid) {
    throw new Error(validator.errors.map(error => `config object at ${error.instancePath.replaceAll("/", ".")}: ${error.message}`).join("\n"))
  }
main.ts:41
Before
41
        const fetchCommands = (await getBranchNames(repoConfig, repoName)).map(branch => `git -C ${location} fetch origin ${branch}:${branch}`).join('; ')
After
41
        const {branches, tags} = await getBranchesAndTags(repoConfig, repoName)
        const branchNames = branches.map(branch => branch.name)
        const tagNames = branches.map(tag => tag.name)
        const fetchCommands = branchNames.concat(tagNames).map(ref => `git -C ${location} fetch origin ${ref}:${ref}`).join('; ')
main.ts:109
Before
109
          for (let branch of await getBranchNames(repoConfig, repoName)) {
After
109
          const branchesAndTags = await getBranchesAndTags(repoConfig, repoName)
          const branchNames = branchesAndTags.branches.map(branch => branch.name)
          const tagNames = branchesAndTags.tags.map(tag => tag.name)
          for (let branch of branchNames) {
main.ts:119
Before
119
After
119
          for (let tag of tagNames) {
            await exec(`(cd ${tempDirRepoPath} && git checkout ${tag})`)
            for (let buildStep of repoConfig.buildSteps) {
              // Run the command for each step in each branch
              await exec(`(cd ${tempDirRepoPath} && ${buildStep.command})`)
              // Copy the specified folders from the "from" to the "to" dir
              await exec(`cp -r ${tempDirRepoPath}/${buildStep.copyFrom} ${directories.output}${eleventyConfig.getFilter("slugify")(repoName)}/tags/${eleventyConfig.getFilter("slugify")(tag)}/${buildStep.copyTo}`)
            }
          }
schemas/ReposConfiguration.json:5
Before
5
        "branchesToPull": {
After
5
        "branches": {
schemas/ReposConfiguration.json:114
Before
114
115
116
117
                  "glob": {
                    "type": "string"
                  },
                  "glob",
After
114
115
116
117
                  },
                  "pattern": {
                    "type": "string"
                  "pattern",
schemas/ReposConfiguration.json:135
Before
135
        "branchesToPull"
After
135
        "branches"
src/configTypes.ts:11
Before
11
 *       branchesToPull: ['main', 'develop']
After
11
 *       branches: ['main', 'develop']
src/configTypes.ts:53
Before
53
54
  branchesToPull: Array<string | {pattern: string, max?: number, compareTo?: string, description?: string}>,
  tags?: Array<string | {glob: string, max: number}>,
After
53
54
  branches: Array<string | {pattern: string, max?: number, compareTo?: string, description?: string}>,
  // todo: make tags optional (and branches, too?) and auto-populate with ** if it's not filled in.
  tags: Array<string | {pattern: string, max: number}>,
src/repos.ts:14
Before
14
15
16
17
18
19
20
const branchesForReposMap: Map<string, Array<{name: string, description?: string, compareTO?: string}>> = new Map()

const getBranches = async (repoConfig: GitConfig, repoName: string): Promise<Array<{name: string, description?: string, compareTo?: string}>> => {
    return cachedBranchNames
  // Get all branches available in the repository
  // Sort the list of branch descriptions from branchesToPull by the length
  let branchRules: Array<{pattern: string, matches: Array<string>, rules: RulesObject}> = repoConfig.branchesToPull.map((branchDescription) => {
After
14
15
16
17
18
19
20
const branchesForReposMap: Map<string, Array<{name: string, description?: string, compareTo?: string}>> = new Map()
const tagsForReposMap: Map<string, Array<{name: string}>> = new Map()

const getBranchesAndTags = async (
  repoConfig: GitConfig,
  repoName: string
): Promise<{
  branches: Array<{name: string, description?: string, compareTo?: string}>,
  tags: Array<{name: string}>,
}> => {
  const cachedTagNames = tagsForReposMap.get(repoName)
    return {branches: cachedBranchNames, tags: cachedTagNames}
  // Get all branches and tags available in the repository
  const allTags = (await exec(`git -C ${repoConfig.location} tag`)).stdout.split("\n").filter(tag => tag !== '')
  // Sort the list of branch descriptions from `branches` by the length
  let branchRules: Array<{pattern: string, matches: Array<string>, rules: RulesObject}> = repoConfig.branches.map((branchDescription) => {
src/repos.ts:47
Before
47
After
47
  let tagRules: Array<{pattern: string, matches: Array<string>, rules: RulesObject}> = repoConfig.tags.map((tagDescription) => {
    const rules: RulesObject = {}

    if (typeof tagDescription !== 'string') {
      if (tagDescription.max) { rules.max = tagDescription.max }
    }

    return {
      pattern: (typeof tagDescription === 'string' ? tagDescription : tagDescription.pattern),
      matches: [],
      rules,
    }
  })

  tagRules.sort((a, b) => b.pattern.length - a.pattern.length)
src/repos.ts:66
Before
66
After
66
  allTags.forEach((tagName) => {
    const matchingPatternIndex = tagRules.findIndex((tagRule) => {
      return minimatch(tagName, tagRule.pattern)
    })

    if (matchingPatternIndex === -1) { return }

    const matchedRule = tagRules[matchingPatternIndex]
    matchedRule.matches.push(tagName)
    if (
      matchedRule.rules?.max
      && matchedRule.rules?.max < matchedRule.matches.length
    ) {
      matchedRule.matches.pop()
    }
  })
src/repos.ts:79
Before
79
80
81
82
83
84

  return branches
}

const getBranchNames = async (repoConfig, repoName) => {
  return (await getBranches(repoConfig, repoName)).map(branch => branch.name)
After
79
80
81
82
83
84
  const tags: Array<{ name: string }> = tagRules.map((tagRule) => {
    return tagRule.matches.map((match) => {
      const result = {name: match}
      return result
    }).flat()
  }).flat()

  if (tagsForReposMap.get(repoName) === undefined) {
    tagsForReposMap.set(repoName, tags)
  }
  return { branches, tags }
src/repos.ts:100
Before
100
101
102
    const branchesToAdd = await getBranches(reposConfig.repos[repoName], repoName)
    for (const branchName of await getBranchNames(reposConfig.repos[repoName], repoName)) {
    const branches = await Promise.all(branchesToAdd.map(async (branch) => {
After
100
101
102
    const branchesAndTags = await getBranchesAndTags(reposConfig.repos[repoName], repoName)
    const branchNames = branchesAndTags.branches.map(branch => branch.name)
    for (const branchName of branchNames) {
    const branches = await Promise.all(branchesAndTags.branches.map(async (branch) => {
src/repos.ts:122
Before
122
      const branchDescription = branchesToAdd.find(branchToAdd => branchToAdd.name === branch.name)
After
122
      const branchDescription = branchesAndTags.branches.find(branchToAdd => branchToAdd.name === branch.name)
src/repos.ts:172
Before
172
export {repos, getBranchNames}
After
172
export {repos, getBranchesAndTags}