import { ActionConfig } from "../ActionConfig"; import { cmd } from "../CommandRunner"; import { CurrentCommitResolver } from "./CurrentCommitResolver"; export class DefaultCurrentCommitResolver implements CurrentCommitResolver { private branch: string; constructor(config: ActionConfig) { this.branch = config.branch; } public async ResolveAsync(): Promise { if (this.branch === 'HEAD') { return (await cmd('git', 'rev-parse', 'HEAD')).trim(); } return this.branch; } public async IsEmptyRepoAsync(): Promise { let lastCommitAll = (await cmd('git', 'rev-list', '-n1', '--all')).trim(); return lastCommitAll === ''; } }