Fix bug and type errors in the ahead/behind logic

4eaa3dddd63389489930c933e2fb2e90d60c5520

Tucker McKnight | Tue Jan 20 2026

Fix bug and type errors in the ahead/behind logic

Also display the ahead/behidn count on the branches page.
js_templates/branches.ts:19
Before
19
                <div class="card-body">${branch.description || ''}</div>
After
19
                <div class="card-body">
                  <p>${branch.description || ''}</p>
                  <p>${branch.ahead} commits ahead, ${branch.behind} commits behind <span class="font-monospace">${branch.compareTo}</span></p>
                </div>
src/branches.ts:13
Before
13
      if (branch.compareTo) { result['compareTo'] = branch.compareTo }
After
13
        compareTo: branch.compareTo,
        ahead: branch.ahead,
        behind: branch.behind,
src/dataTypes.ts:6
Before
6
    compareTo?: string,
After
6
    ahead: number,
    behind: number,
    compareTo: string,
src/repos.ts:121
Before
121
122
    branches.forEach((branch) => {
      const compareToBranch = branches.find((test) => test.name = compareTo)
After
121
122
    const branchesWithCompareToInfo: Repository['branches'] = branches.map((branch) => {
      const compareToBranch = branches.find((test) => test.name === compareTo)
src/repos.ts:142
Before
142
143
144
145
146
147
148
      const onlyInThisBranch = thisBranchCommits.difference(compareToBranchCommits).size
      const onlyInCompareToBranch = compareToBranchCommits.difference(thisBranchCommits).size
      
      branch['ahead'] = onlyInThisBranch
      branch['behind'] = onlyInCompareToBranch
      branch['compareTo'] = compareTo
      branches,
After
142
143
144
145
146
147
148
      const onlyInThisBranch = Array.from(thisBranchCommits).filter(thisBranchCommit => !compareToBranchCommits.has(thisBranchCommit)).length
      const onlyInCompareToBranch = Array.from(compareToBranchCommits).filter(compareToBranchCommit => !thisBranchCommits.has(compareToBranchCommit)).length

      const compareToInfo = {
        ahead: onlyInThisBranch,
        behind: onlyInCompareToBranch,
        compareTo: compareTo,
      }

      return {...branch, ...compareToInfo}
      branches: branchesWithCompareToInfo,