Tucker McKnight <tmcknight@instructure.com> | Sat Jun 20 2026
DRY up the part where we get the head and file list of each branch and tag
153 154 155 156 157
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()153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
const repoNames = Object.keys(reposConfig.repos)
cachedRepos = []
const getRefShaAndFileList = async (ref, refType: 'branch' | 'tag', repoName: string, repoLocation: string) => {
const refHeadRes = await exec(`git -C ${repoLocation} show-ref refs/${refType === 'branch' ? 'heads' : 'tags'}/${ref.name}`)
const refHead = refHeadRes.stdout.split(" ")[0]
const result = {
name: ref.name,
sha: refHead,
fileList: await getFileList(ref.name, repoLocation)
}
if (ref.description) { result['description'] = ref.description }
if (ref.compareTo) { result['compareTo'] = ref.compareTo }
return result
}
for (const repoName of repoNames) {
const repoLocation = getLocation(reposConfig, outputDir, repoName, slugify)
const commits: Repository['commits'] = new Map()163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
}
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 = {
name: branch.name,
sha: branchHead,
fileList: await getFileList(branch.name, repoLocation)
}
if (branch.description) { result['description'] = branch.description }
if (branch.compareTo) { result['compareTo'] = branch.compareTo }
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) => {163 164 165 166 167 168 169 170 171 172
}
const branches = await Promise.all(branchesAndTags.branches.map(async (branch) => {
return getRefShaAndFileList(branch, 'branch', repoName, repoLocation)
}))
const tags = await Promise.all(branchesAndTags.tags.map(async (tag) => {
return getRefShaAndFileList(tag, 'tag', repoName, repoLocation)
}))
const branchesWithCompareToInfo: Repository['branches'] = branches.map((branch) => {