MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / listProjectCommits

Function listProjectCommits

desktop/project-git/project-commits.ts:98–130  ·  view source on GitHub ↗
(
  projectId: string,
  limit?: number | undefined | null,
)

Source from the content-addressed store, hash-verified

96}
97
98export async function listProjectCommits(
99 projectId: string,
100 limit?: number | undefined | null,
101): Promise<ProjectCommitEntry[]> {
102 if (!(await isGitRepository(projectId))) {
103 return []
104 }
105
106 const normalizedLimit = Math.min(Math.max(limit ?? 50, 1), 200)
107
108 let stdout = ''
109
110 try {
111 ;({ stdout } = await runGitWithOptions(
112 projectId,
113 [
114 'log',
115 '-z',
116 `--max-count=${normalizedLimit}`,
117 '--decorate=short',
118 `--format=${COMMIT_PRETTY_FORMAT}`,
119 ],
120 {
121 timeout: 10_000,
122 maxBuffer: 1024 * 1024 * 4,
123 },
124 ))
125 } catch {
126 return []
127 }
128
129 return parseCommitEntries(stdout)
130}

Callers 1

loadProjectCommitHistoryFunction · 0.90

Calls 3

isGitRepositoryFunction · 0.90
runGitWithOptionsFunction · 0.90
parseCommitEntriesFunction · 0.85

Tested by

no test coverage detected