diff --git a/src/main.ts b/src/main.ts index 657f741..05eb204 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,10 +32,6 @@ export async function main(sourceRepo: Repo, targetRepo: Repo, dryRun: boolean, console.log(`DEBUG - sourceRepoCloneCommand: ${sourceRepoCloneCommand}`); execSync(sourceRepoCloneCommand); execSync(`git clone https://${repoString(targetRepo)} ${TARGET_DIR}`); - // Seems like setting `--author` on `git commit` is not sufficient - still need to set `user` as well (I guess those - // are the difference between `comitted by` and `written by`?) - execSync(`git config --global user.email "commit-report-sync-bot@scubbo.org"`, { cwd: TARGET_DIR }); - execSync(`git config --global user.name "Commit Report Sync Bot"`, { cwd: TARGET_DIR }); // Logic: // * Go back as far in source commit history as the given number of commits @@ -245,6 +241,15 @@ function createRepresentativeCommit(sourceRepo: Repo,sourceCommit: Commit) { cwd: TARGET_DIR }) + // Seems like setting `--author` on `git commit` is not sufficient - still need to set `user` as well (I guess those + // are the difference between `comitted by` and `written by`?) + // Confirmed by following the instructions [here](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-profile/managing-contribution-settings-on-your-profile/why-are-my-contributions-not-showing-up-on-my-profile#your-local-git-commit-email-isnt-connected-to-your-account) + // to check the "made by" address, and confirming that it did not match the email set in the `--author` flag. + // Note that, contrary to advice given by the CLI, this does not use the global config, but the local one - because, + // otherwise, if this was run locally, it would mess up the host system's config. + execSync(`git config user.email "${sourceCommit.author_email}"`, { cwd: TARGET_DIR }); + execSync(`git config user.name "${sourceCommit.author_name}"`, { cwd: TARGET_DIR }); + try { // Do _not_ arbitrarily remove the `hash` - it's used for signalling identity in `main()` const args = `"${sourceRepo.owner}/${sourceRepo.name}: ${sourceCommit.message} - ${sourceCommit.hash}" --date="${format(sourceCommit.date, 'yyyy-MM-dd HH:mm:ss')}" --author="${sourceCommit.author_name} <${sourceCommit.author_email}>"`;