feat(rawDump): add parent_ids to commit payload
Include parent commit hashes in raw dump commit reporting. - git log format now includes %P (parent hashes) - parseCommitLog extracts parent_ids as string array - CommitPayload type extended with parent_ids field - merge commits may have multiple parents Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
a76c92ea2d
commit
ad90f40088
|
|
@ -77,15 +77,17 @@ export function parseCommitLog(output: string): Array<{
|
|||
commit_time: string
|
||||
git_user_name: string
|
||||
git_user_email: string
|
||||
parent_ids: string[]
|
||||
subject: string
|
||||
}> {
|
||||
if (!output.trim()) return []
|
||||
return output
|
||||
.split('\n')
|
||||
.map((line) => {
|
||||
const [commit_id, commit_time, git_user_name, git_user_email, ...rest] = line.split('|')
|
||||
const [commit_id, commit_time, git_user_name, git_user_email, parent_ids_str, ...rest] = line.split('|')
|
||||
if (!commit_id || !git_user_email) return null
|
||||
return { commit_id, commit_time, git_user_name, git_user_email, subject: rest.join('|') }
|
||||
const parent_ids = parent_ids_str ? parent_ids_str.trim().split(' ').filter(Boolean) : []
|
||||
return { commit_id, commit_time, git_user_name, git_user_email, parent_ids, subject: rest.join('|') }
|
||||
})
|
||||
.filter((item): item is NonNullable<typeof item> => !!item)
|
||||
}
|
||||
|
|
@ -96,12 +98,12 @@ export async function getCommitLog(cwd: string, lastCommit?: string): Promise<st
|
|||
|
||||
if (lastCommit) {
|
||||
return gitExec(
|
||||
['log', `${lastCommit}..HEAD`, '--reverse', '--max-count=50', ...authorFilter, '--format=%H|%aI|%an|%ae|%s'],
|
||||
['log', `${lastCommit}..HEAD`, '--reverse', '--max-count=50', ...authorFilter, '--format=%H|%aI|%an|%ae|%P|%s'],
|
||||
cwd,
|
||||
)
|
||||
}
|
||||
return gitExec(
|
||||
['log', '--since=1 day ago', '--reverse', '--max-count=50', ...authorFilter, '--format=%H|%aI|%an|%ae|%s'],
|
||||
['log', '--since=1 day ago', '--reverse', '--max-count=50', ...authorFilter, '--format=%H|%aI|%an|%ae|%P|%s'],
|
||||
cwd,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,4 +87,5 @@ export interface CommitPayload {
|
|||
files: string[]
|
||||
comment: string
|
||||
subject: string
|
||||
parent_ids: string[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -599,6 +599,7 @@ export async function uploadCommits(
|
|||
files: extractFilesFromDiff(diff),
|
||||
comment: toCommitComment(commit.subject),
|
||||
subject: commit.subject,
|
||||
parent_ids: commit.parent_ids,
|
||||
}
|
||||
await postJson(authData.baseUrl, authData.headers, '/raw-store/commit', body as unknown as Record<string, unknown>)
|
||||
// 每成功一个 commit 立即更新 state,避免失败后全部重传
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user