DRY up the part where we get the head and file list of each branch and tag

0da2e3bfb4fac0986c35ad3b429bdae9af36895f

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
src/repos.ts:154
Before
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()
After
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()
src/repos.ts:164
Before
After