Set user.email and user.name to original commit's

As per comment, seems like `--author` is not sufficient for
contributions to be counted.

Note that this also undoes the previous logic of setting this value
locally, as that would cause disruption to the local system if this
logic was ever run on a long-running system (such as, for instance, a
development machine)
This commit is contained in:
Jack Jackson 2025-03-03 13:51:05 -08:00
parent 0f714976b0
commit 27594e248b

View File

@ -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
@ -238,6 +234,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}>"`;