Tucker McKnight
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.
1
import repos from './src/repos.ts'
1
import {repos, getBranchNames} from './src/repos.ts'
42
const fetchCommands = repoConfig.branchesToPull.map(branch => `git -C ${location} fetch origin ${branch}:${branch}`).join('; ')
42
const fetchCommands = (await getBranchNames(repoConfig, repoName)).map(branch => `git -C ${location} fetch origin ${branch}:${branch}`).join('; ')
110
for (let branch of repoConfig.branchesToPull) {
110
for (let branch of await getBranchNames(repoConfig, repoName)) {
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
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're here, then the "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
33 34
const branchNames = getBranchNames(reposConfig.repos[repoName])
const repoLocation = getLocation(reposConfig, outputDir, repoName)
33 34
const repoLocation = getLocation(reposConfig, outputDir, repoName)
const branchNames = await getBranchNames(reposConfig.repos[repoName], repoName)
65
export default repos
65
export {repos, getBranchNames}
21
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.