import { createLogger } from '../../shared/utils/index.js';
import { parseDistinctHashes, runGit } from './branchGitCommands.js';
const log = createLogger('branchGitResolver');
export function resolveBranchEntryPointFromReflog(gitCwd, branch) {
    try {
        const output = runGit(gitCwd, ['reflog', 'show', '--format=%H', branch]);
        const hashes = parseDistinctHashes(output).reverse();
        if (hashes.length < 2) {
            return null;
        }
        return {
            baseCommit: hashes[0],
            firstCommit: hashes[1],
        };
    }
    catch (error) {
        log.debug('Failed to resolve branch entry point from reflog', { error: String(error), gitCwd, branch });
        return null;
    }
}
export function readCommitSubject(gitCwd, commit) {
    return runGit(gitCwd, ['show', '-s', '--format=%s', commit]);
}
//# sourceMappingURL=branchEntryPointResolver.js.map