| 86 | } |
| 87 | |
| 88 | function getLogLikeHandler(cwd: string, limit: number, skip = 0): { commits: ParsedLogEntry[]; hasMore: boolean } { |
| 89 | const format = ["%H", "%h", "%s", "%an", "%aI", "%ar", "%P"].join(FIELD_SEPARATOR) + RECORD_SEPARATOR |
| 90 | const output = gitExec(`git log --format='${format}' --max-count=${limit + 1} --skip=${skip}`, cwd) |
| 91 | |
| 92 | const commits = output |
| 93 | .split(RECORD_SEPARATOR) |
| 94 | .map((record) => record.trim()) |
| 95 | .filter(Boolean) |
| 96 | .map((record): ParsedLogEntry => { |
| 97 | const [rawSha = "", rawShortSha = "", message = "", author = "", rawDate = "", rawRelativeDate = "", rawParents = ""] = |
| 98 | record.split(FIELD_SEPARATOR) |
| 99 | const sha = rawSha.trim() |
| 100 | const shortSha = rawShortSha.trim() |
| 101 | const date = rawDate.trim() |
| 102 | const relativeDate = rawRelativeDate.trim() |
| 103 | const parents = rawParents.trim() |
| 104 | const parentCount = parents.trim() ? parents.trim().split(/\s+/).length : 0 |
| 105 | return { sha, shortSha, message, author, date, relativeDate, parentCount } |
| 106 | }) |
| 107 | |
| 108 | return { |
| 109 | commits: commits.slice(0, limit), |
| 110 | hasMore: commits.length > limit, |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | function getCommitFilesLikeHandler(cwd: string, commit: string): ParsedNameStatusFile[] { |
| 115 | const parents = gitExec(`git show --no-patch --format=%P ${commit}`, cwd).trim().split(/\s+/).filter(Boolean) |