Skip to content

Commit

Permalink
commit messages
Browse files Browse the repository at this point in the history
  • Loading branch information
SPRINX0\prochazka committed Feb 19, 2025
1 parent 119ad3a commit 5538d43
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/diflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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') {
Expand Down
8 changes: 6 additions & 2 deletions src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ export async function runGitCommand(repoPath: string, cmd: string): Promise<stri
}

export async function getCommits(repoPath: string, branch: string): Promise<Commit[]> {
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);
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5538d43

Please sign in to comment.