Fix blocking issues in convert-sha256 · Entire

Fix blocking issues in convert-sha256

b8d4096→main·

nodo·1mo ago·3 files·+181 added/-81 removed

  1. 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 update forever — the .gitmodules upstream still advertises only SHA1. Refuse any submodule gitlink in discoverReachable; keep a defensive guard in translateTree.

  2. --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.

  3. 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.

  4. --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 res through 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

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