spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / git / tiers / branch-source-of / branch-source-of.ts
25 lines · 708 BRaw
1import type Types from '../../types'
2
3/**
4 * What branch mode's diff compares, given its resolved base: the merge
5 * base, HEAD under the default branch's label, or the plain working tree.
6 *
7 * @param base the resolved base
8 * @returns the source the rows are labelled with
9 */
10export function branchSourceOf(
11 base: Types.ResolvedBranchBase,
12): Types.DiffSource {
13 switch (base.kind) {
14 case 'merge-base':
15 return {
16 kind: 'branch',
17 baseBranch: base.baseBranch,
18 baseRef: base.mergeBase,
19 }
20 case 'head-is-base':
21 return { kind: 'branch', baseBranch: base.baseBranch, baseRef: 'HEAD' }
22 case 'none':
23 return { kind: 'working-tree', base: 'HEAD' }
24 }
25}