Tucker McKnight <tmcknight@instructure.com> | Mon May 18 2026
Mistaken idea about having each branch have a full list of commits The previous commit, in the file-caching branch, also is based on this idea. I'll need to undo that as well. Putting this in a branch and saving it somewhere so that I can more easily see what I was doing to undo it later.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
const flatPatches: Array<FlatPatchRecord> = []
let currentCommit: ReturnType<Repository['commits']['get']> | undefined = repo.commits.get(branch.sha)
while (currentCommit !== undefined) {
flatPatches.push({
type: "branch",
commit: currentCommit,
repoName: repo.name,
refName: branch.name
})
currentCommit = repo.commits.get(currentCommit.parent)
}
return flatPatches
})17 18 19 20 21 22 23 24 25 26 27 28 29
const flatPatches: Array<FlatPatchRecord> = []
let currentCommit: ReturnType<Repository['commits']['get']> | undefined = repo.commits.get(branch.sha)
flatPatches.concat(branch.commits.map((commit) => {
return {
type: "branch",
commit,
repoName: repo.name,
refName: branch.name
}
})
return flatPatches
})34 35 36 37 38
const tags = repo.tags.flatMap((tag) => {
const flatPatches: Array<FlatPatchRecord> = []
let currentCommit: ReturnType<Repository['commits']['get']> = repo.commits.get(tag.sha)
while (currentCommit !== undefined) {
flatPatches.push({
type: "tag",34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
const tags = repo.tags.flatMap((tag) => {
const flatPatches: Array<FlatPatchRecord> = []
let currentCommit: ReturnType<Repository['commits']['get']> = repo.commits.get(tag.sha)
flatPatches.concat(branch.commits.map((commit) => {
return {
type: "tag",
commit,
repoName: repo.name,
refName: branch.name
}
})
while (currentCommit !== undefined) {
flatPatches.push({
type: "tag",5 6 7 8 9 10
import childProcess from 'child_process'
import {minimatch} from 'minimatch'
import { type Repository} from './dataTypes.ts'
import cloneUrl from './vcses/git/helpers.ts'
import { addBranchToCommitsMap } from './vcses/git/operations.ts'
import { getLocation} from './helpers.ts'5 6 7 8 9 10
import childProcess from 'child_process'
import {minimatch} from 'minimatch'
import { type Repository, type Commit } from './dataTypes.ts'
import cloneUrl from './vcses/git/helpers.ts'
import { addBranchToCommitsMap } from './vcses/git/operations.ts'
import { getLocation} from './helpers.ts'148 149 150 151 152 153 154 155 156
const commits: Repository['commits'] = new Map()
const branchesAndTags = await getBranchesAndTags(reposConfig.repos[repoName], repoName)
const branchNames = branchesAndTags.branches.map(branch => branch.name)
for (const branchName of branchNames) {
await addBranchToCommitsMap(branchName, repoLocation, commits)
}
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}`)148 149 150 151 152 153 154 155 156 157 158 159 160
const commits: Repository['commits'] = new Map()
const branchesAndTags = await getBranchesAndTags(reposConfig.repos[repoName], repoName)
const branchNames = branchesAndTags.branches.map(branch => branch.name)
const branchCommits: Map<string, Array<Commit>> = new Map()
for (const branchName of branchNames) {
branchCommits.set(branchName, await addBranchToCommitsMap(branchName, repoLocation, commits))
// once we've iterated through here, the commits map is fully filled in
}
// TODO: don't have this happen in a second loop that waits for things -- can this all
// be done at once?
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}`)159 160 161 162 163 164
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 }159 160 161 162 163 164 165
const result = {
name: branch.name,
sha: branchHead,
fileList: await getFileList(branch.name, repoLocation),
commits: branchCommits.get(branch.name)
}
if (branch.description) { result['description'] = branch.description }
if (branch.compareTo) { result['compareTo'] = branch.compareTo }1 2 3 4 5 6
import childProcess from 'child_process'
const exec = util.promisify(childProcess.exec)
import { getGitDiffsFromPatchText} from '../../helpers.ts'
import { type Repository, type FileInfo } from '../../dataTypes.ts'
export const getFileList = async (
branchName: string, repoLocation: string1 2 3 4 5 6
import childProcess from 'child_process'
const exec = util.promisify(childProcess.exec)
import { getGitDiffsFromPatchText} from '../../helpers.ts'
import { type Repository, type FileInfo, type Commit } from '../../dataTypes.ts'
export const getFileList = async (
branchName: string, repoLocation: string92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
gitLogSubset = gitLogSubset.slice(nextPatchStart)
const hash = currentPatch[0].replace("commit ", "").trim()
console.log(`doing ${hash}`)
// set the parent hash of the previous commit, unless we're on the first commit
if (previousHash !== null) {
commits.get(previousHash)['parent'] = hash
}
previousHash = hash
// exit early if the commits map already includes this hash
if (commits.has(hash)) {
return
}
let author: string, date: string, isMerge: boolean92 93 94 95 96 97 98 99 100
gitLogSubset = gitLogSubset.slice(nextPatchStart)
const hash = currentPatch[0].replace("commit ", "").trim()
// exit early if the commits map already includes this hash
if (commits.has(hash)) {
continue
}
let author: string, date: string, isMerge: boolean135 136 137 138 139 140
}).join("\n").trim()
const diffs = getGitDiffsFromPatchText(currentPatch.slice(diffStart).join("\n"))
commits.set(hash, {
hash,
message: commitMessage,
isMerge: isMerge || false,135 136 137 138 139 140 141
}).join("\n").trim()
const diffs = getGitDiffsFromPatchText(currentPatch.slice(diffStart).join("\n"))
let commit = {
hash,
message: commitMessage,
isMerge: isMerge || false,144 145 146 147 148 149 150 151 152
diffs,
parent: null,
cachedFiles: new Map(),
})
} while (gitLogSubset.length > 1)
return previousHash
}
export type BlameInfo = {144 145 146 147 148 149 150 151 152 153 154 155
diffs,
parent: null,
cachedFiles: new Map(),
}
orderedCommits.push(commit)
commits.set(hash, commit)
} while (gitLogSubset.length > 1)
return orderedCommits
}
export type BlameInfo = {