Allow globs to be used instead of branch names

e2d4fdec19aca05ed79683f775ca083cab61baf9

Tucker McKnight | Sun Jan 18 2026

Allow globs to be used instead of branch names

The max value still doesn't do anything, but the glob string does.
All branches matching a glob string will be added to the list of branches
to be included in the site.

This is also the list of branches that is used to determine which branches
should be pulled when the eleventy.beforeConfig clones its copy of the
repository.
main.ts:1
Before
1
import repos from './src/repos.ts'
After
1
import {repos, getBranchNames} from './src/repos.ts'
main.ts:42
Before
42
        const fetchCommands = repoConfig.branchesToPull.map(branch => `git -C ${location} fetch origin ${branch}:${branch}`).join('; ')
After
42
        const fetchCommands = (await getBranchNames(repoConfig, repoName)).map(branch => `git -C ${location} fetch origin ${branch}:${branch}`).join('; ')
main.ts:110
Before
110
          for (let branch of repoConfig.branchesToPull) {
After
110
          for (let branch of await getBranchNames(repoConfig, repoName)) {
src/repos.ts:2
Before
2
3
4
5
6
7
import { type Repository} from './dataTypes.ts'
import cloneUrl from './vcses/git/helpers.ts'
const getBranchNames = (repoConfig: GitConfig): Array<string> => {
  return repoConfig.branchesToPull.map((branch) => {
      return branch
      return "" // todo
After
2
3
4
5
6
7
import path from 'path'
import { type Repository} from './dataTypes.ts'
import cloneUrl from './vcses/git/helpers.ts'
const branchesForReposMap: Map<string, string[]> = new Map()

const getBranchNames = async (repoConfig: GitConfig, repoName: string): Promise<Array<string>> => {
  const cachedBranchNames = branchesForReposMap.get(repoName)
  if (cachedBranchNames !== undefined) {
    return cachedBranchNames
  }

  // Get all branches available in the repository
  const allBranches = (await exec(`git -C ${repoConfig.location} branch --format="%(refname:short)"`)).stdout.split("\n")
  const matchingBranchesFromGlobs: Map<string, string[]> = new Map()
  const literalBranchNames: string[] = []

  repoConfig.branchesToPull.forEach((branch) => {
      literalBranchNames.push(branch)
      // If we&#39;re here, then the &quot;branch" was an object like:
      // { glob: string, max: number }
      // TODO: figure out which branch is the newest/oldest, and
// keep them less than `max` by kicking out the oldest from the list.
      const glob = branch['glob']
      const matching = allBranches.filter((possibleBranch) => {
        const match = path.matchesGlob(possibleBranch, glob)
        return match
      })
      matchingBranchesFromGlobs.set(
        glob,
        (matchingBranchesFromGlobs.get(glob) || []).concat(matching)
      )

  const matchedBranchesFromGlobs = Array.from(matchingBranchesFromGlobs.values()).flat()
  const branchNames: string[] = Array.from(new Set(matchedBranchesFromGlobs.concat(literalBranchNames)))

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

  return branchNames
src/repos.ts:33
Before
33
34
    const branchNames = getBranchNames(reposConfig.repos[repoName])
      const repoLocation = getLocation(reposConfig, outputDir, repoName)
After
33
34
    const repoLocation = getLocation(reposConfig, outputDir, repoName)
    const branchNames = await getBranchNames(reposConfig.repos[repoName], repoName)
src/repos.ts:65
Before
65
export default repos
After
65
export {repos, getBranchNames}
wiki/projects/branch-globs.md:21
Before
21
After
21


## Jan 17, 2026

- Update getBranchNames so that it 1) pulls all branches from the repo, and 2)
  figures out which ones match the given branch globs.
- where does that get called?
  - it gets called when `repos()` is called
  - and `repos()` get called when main.ts runs, so after the beforehook is called.
  - we'll need to decide which branches get pulled in the before hook, so that the clone
    only pulls the branches we want
  - for a first-attempt solution, make a function that figures out which branches
    are available and call it multiple times: once when pulling the branches, and then also
    in subsequent calls when we're seeing which branches are available in the repo.
    - So, stop calling `repoConfig.branchesToPull` directly
  - currently failing locally because I don't have the updated beforeHook on this
    laptop. Push current work, update local repo to use the beforeHook from the
    clone-early branch, and see if that works. (update: Yes, that was the problem.)
    - this is a good reason to put the deployed repo config on the public site, too.
      I currently have different example site configs between my laptop and the deployed
      site.