Recreate target commit history after inserting-after-HEAD

This commit is contained in:
Commit Report Sync Bot 2025-03-01 23:46:52 -08:00
parent c13ece3f65
commit 7e843c59e7
9 changed files with 31 additions and 1 deletions

26
.gitea/workflows/main.yml Normal file
View File

@ -0,0 +1,26 @@
# I Am A Strange Loop
name: Mirror to GitHub
run-name: Mirror to GitHub
on: [push]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# If I were going to make this as a template, I'd instead use the `${{ github.[...] }} context to determin owner
# and name directly from the context.
# I'm leaving that off because it'd require a whole other step (to pipe `github.repository` through a splitting
# tool, because there's only `github.repository_owner`, no `github.repository_name`)
#
# (And the token should be retrieved from Vault)
# Using `github.ref` just in case there's any race condition ambiguity.
- uses: https://gitea.scubbo.org/scubbo/commit-report-sync@${{ github.ref}}
with:
target_repo_domain: github.com
target_repo_owner: scubbo
target_repo_name: gitea-commit-mirror
source_repo_domain: gitea.scubbo.org
source_repo_owner: scubbo
source_repo_name: commit-report-sync
token_for_target_repo: ${{ secrets.PAT_FOR_GITHUB_SYNC }}

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
!node_modules/
!dist/
!.gitea/
working/

2
dist/index.js vendored
View File

@ -25838,6 +25838,8 @@ async function main(sourceRepo, targetRepo, dryRun, tokenForTargetRepo) {
else {
console.log(`DEBUG - could not find a targetCommit that is earlier than or equal to the sourceCommit ${sourceCommit.hash} - therefore, writing the source commit's representation onto the current HEAD of target repo`);
insertRepresentativeCommit(sourceRepo, sourceCommit, undefined, undefined);
// As above, have to regenerate history after mutation
targetCommitHistory = buildTargetCommitHistory(TARGET_DIR, sourceCommit.date);
}
}
// OK, that's it - we've processed all the source commits, and we've inserted all the necessary target commits.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -110,8 +110,9 @@ export async function main(sourceRepo: Repo, targetRepo: Repo, dryRun: boolean,
} else {
console.log(`DEBUG - could not find a targetCommit that is earlier than or equal to the sourceCommit ${sourceCommit.hash} - therefore, writing the source commit's representation onto the current HEAD of target repo`);
insertRepresentativeCommit(sourceRepo, sourceCommit, undefined, undefined);
// As above, have to regenerate history after mutation
targetCommitHistory = buildTargetCommitHistory(TARGET_DIR, sourceCommit.date);
}
}
// OK, that's it - we've processed all the source commits, and we've inserted all the necessary target commits.
// We can just `git push` to the target repo now.