feat(sync): add resolveBranchHead to fetch branch tip SHA

This commit is contained in:
Gabriel Brown
2026-07-11 13:39:36 -04:00
parent 696f03e867
commit c8200a6747
2 changed files with 34 additions and 0 deletions
@@ -0,0 +1,24 @@
import type { Octokit } from '@octokit/rest';
import { describe, expect, it, vi } from 'vitest';
import { resolveBranchHead } from '../../convex/githubClient';
describe('resolveBranchHead', () => {
it('returns the branch tip sha from the branch ref', async () => {
const getBranch = vi.fn(async () => ({
data: { commit: { sha: 'deadbeef' } },
}));
const octokit = {
rest: { repos: { getBranch } },
} as unknown as Octokit;
const result = await resolveBranchHead(octokit, 'o', 'r', 'main');
expect(result.sha).toBe('deadbeef');
expect(getBranch).toHaveBeenCalledWith({
owner: 'o',
repo: 'r',
branch: 'main',
});
});
});