diff --git a/src/diflow.test.ts b/src/diflow.test.ts index 72bae8a..7714edc 100644 --- a/src/diflow.test.ts +++ b/src/diflow.test.ts @@ -118,7 +118,7 @@ describe('Git Repository Tests', () => { expect(content3).toBe('content3'); }); - test.only('2 commits in 2 repos', async () => { + test('2 commits in 2 repos', async () => { // await sleep(2000); // Modify file in diff repo diff --git a/src/processor.ts b/src/processor.ts index 603fa65..587c74b 100644 --- a/src/processor.ts +++ b/src/processor.ts @@ -102,8 +102,14 @@ export class Processor { } } -class CommitToProcess { - constructor(public commit: string, public ts: number, public repoid: RepoId) {} +interface CommitToProcess { + commit: string; + ts: number; + authorName: string; + authorEmail: string; + message: string; + authorDate: string; + repoid: RepoId; } class BranchProcessor { @@ -225,7 +231,7 @@ class CommitProcessor { await runGitCommand(this.processor.repoPaths[repoid], `add -A`); await runGitCommand( this.processor.repoPaths[repoid], - `commit -m "CI: Auto commit changes in ${repoid} for branch ${this.branchProcessor.branch}"` + `commit -m "SYNC: ${this.commit.message}" --author="${this.commit.authorName} <${this.commit.authorEmail}>" --date="${this.commit.authorDate}"` ); await runGitCommand(this.processor.repoPaths[repoid], `push`); if (repoid !== 'config') { diff --git a/src/tools.ts b/src/tools.ts index 43dfd5b..dda5d1e 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -19,15 +19,19 @@ export async function runGitCommand(repoPath: string, cmd: string): Promise { - const log = await runGitCommand(repoPath, `log ${branch} --reverse --pretty=format:"%H|%ct"`); + const log = await runGitCommand(repoPath, `log ${branch} --reverse --pretty=format:"%H|%ct|%aN|%aE|%f|%ad"`); const res = log .split('\n') .filter(Boolean) .map(x => { - const [commit, ts] = x.split('|'); + const [commit, ts, authorName, authorEmail, message, authorDate] = x.split('|'); return { commit, ts: parseInt(ts), + authorName, + authorEmail, + message, + authorDate, }; }); res.sort((a, b) => a.ts - b.ts); diff --git a/src/types.ts b/src/types.ts index c73a07c..43d44c2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,6 +23,10 @@ export interface State { export interface Commit { commit: string; ts: number; + authorName: string; + authorEmail: string; + message: string; + authorDate: string; } export interface ChangeItem {