MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / getBranchCommits

Function getBranchCommits

packages/bumpy/src/core/git.ts:160–187  ·  view source on GitHub ↗
(
  rootDir: string,
  baseBranch: string,
)

Source from the content-addressed store, hash-verified

158
159/** Get commits on the current branch since it diverged from baseBranch */
160export function getBranchCommits(
161 rootDir: string,
162 baseBranch: string,
163): { hash: string; subject: string; body: string }[] {
164 // Ensure we have the base branch ref
165 if (!tryRunArgs(['git', 'rev-parse', '--verify', `origin/${baseBranch}`], { cwd: rootDir })) {
166 tryRunArgs(['git', 'fetch', 'origin', baseBranch, '--depth=1'], { cwd: rootDir });
167 }
168
169 const mergeBase = tryRunArgs(['git', 'merge-base', 'HEAD', `origin/${baseBranch}`], { cwd: rootDir });
170 const ref = mergeBase || `origin/${baseBranch}`;
171
172 const rawLog = tryRunArgs(['git', 'log', `${ref}..HEAD`, '--format=%H%n%s%n%b%n---END---'], { cwd: rootDir });
173 if (!rawLog) return [];
174
175 const commits: { hash: string; subject: string; body: string }[] = [];
176 const entries = rawLog.split('---END---').filter((e) => e.trim());
177 for (const entry of entries) {
178 const lines = entry.trim().split('\n');
179 if (lines.length < 2) continue;
180 commits.push({
181 hash: lines[0]!.trim(),
182 subject: lines[1]!.trim(),
183 body: lines.slice(2).join('\n').trim(),
184 });
185 }
186 return commits;
187}
188
189/** Get files changed in a specific commit */
190export function getFilesChangedInCommit(hash: string, opts?: { cwd?: string }): string[] {

Callers 1

generateCommandFunction · 0.90

Calls 1

tryRunArgsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…