Skip to content

Commit 2279b49

Browse files
authored
Fix upgrade-dep patching system (#4254)
**What type of PR is this?** Bug fix **What does this PR do? Why is it needed?** This was mistakenly broken in a1a0b60 due to attempting to fix a false positive from `go vet`: `conversion from int to string yields a string of one rune, not a string of digits`.
1 parent 8feaa93 commit 2279b49

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

go/tools/releaser/upgradedep.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ func upgradeDepDecl(ctx context.Context, gh *githubClient, workDir, name string,
461461
}
462462
patchName := patchLabelValue[len("//third_party:"):]
463463
patchPath := filepath.Join(rootDir, "third_party", patchName)
464-
prevDir := filepath.Join(workDir, name, fmt.Sprintf("a%d", patchIndex))
465-
patchDir := filepath.Join(workDir, name, fmt.Sprintf("a%d", patchIndex+1))
464+
prevDir := filepath.Join(workDir, name, string(rune('a'+patchIndex)))
465+
patchDir := filepath.Join(workDir, name, string(rune('a'+patchIndex+1)))
466466
var patchCmd []string
467467
for _, c := range comments.Before {
468468
words := strings.Fields(strings.TrimPrefix(c.Token, "#"))
@@ -484,7 +484,7 @@ func upgradeDepDecl(ctx context.Context, gh *githubClient, workDir, name string,
484484
return err
485485
}
486486
}
487-
patch, _ := runForOutput(ctx, filepath.Join(workDir, name), "diff", "-urN", fmt.Sprintf("a%d", patchIndex), fmt.Sprintf("a%d", patchIndex+1))
487+
patch, _ := runForOutput(ctx, filepath.Join(workDir, name), "diff", "-urN", filepath.Base(prevDir), filepath.Base(patchDir))
488488
patch = sanitizePatch(patch)
489489
if err := os.WriteFile(patchPath, patch, 0666); err != nil {
490490
return err

0 commit comments

Comments
 (0)