Fix blocking issues in convert-sha256 · Entire
Fix blocking issues in convert-sha256
b8d4096→main·
nodo·1mo ago·3 files·+181 added/-81 removed
Submodule gitlinks: drop the "vendored" carve-out. Even when the linked-to commit lives in the source store, rewriting the gitlink to SHA256 produces a tree that fsck-passes but breaks
git submodule updateforever — the .gitmodules upstream still advertises only SHA1. Refuse any submodule gitlink in discoverReachable; keep a defensive guard in translateTree.--check HEAD on tag-only conversions: pickHEAD returns "" when no branches landed, so HEAD stays at the PlainInit default refs/heads/master and the HEAD check guarantees a failure after an otherwise successful run. runChecks now takes a hasBranches bool and marks HEAD as skipped when false, with a "tags-only conversion" detail.
Partial signed-tags list dropped on error: signBranchTips returns the tags it created before failing, but Run was assigning res.SignedTags = signed only on the success path and the cobra wrapper dropped result entirely on err. Assign res.SignedTags before the err check, and have the cobra wrapper print the partial result on error so users see which converted/* tags landed and need cleanup.
--keep-source-objects on error paths: the flag's whole purpose is debugging failed conversions, but cleanupTemp was only flipped at the end of Run, so every error before that wiped the temp store. Hoist the cleanupTemp = false / res.TempDir assignment to right after MkdirTemp, and propagate
resthrough every subsequent error return so the kept path surfaces in both Result and Lines() output.
Sessions
Transcript data is unavailable for this checkpoint.
Changes
3
cmd/git-sync
Mconvert_sha256.go+15/-5
internal/sha256convert
Msha256convert.go+96/-76
Msha256convert_test.go+70
The conversion is destructive in two ways the caller should be aware of: GPG signatures on commits and tags are dropped (they sign over the original SHA1 content and would be invalid post-rewrite), and submodule gitlinks that point at a commit outside this repository cannot be embedded in a SHA256 tree — the command exits with an error if it finds any so the caller can convert the submodule repository first.
Example Code Block
result, err := sha256convert.Run(cmd.Context(), req)
if result.SourceURL != "" || result.TargetDir != "" {
printOutput(jsonOutput, result)
}
if err != nil {
return fmt.Errorf("convert-sha256: %w", err)
}
printOutput(jsonOutput, result)
return nil
Notes
- Submodule gitlinks reference a commit in a different repo, which can lead to errors if that commit doesn't exist in the new SHA256 tree.
- Ensure to convert the submodule repository first if necessary to maintain references.