Skip to content

Commit

Permalink
releaser: fix scrubbing timestamp from patch files (#3180)
Browse files Browse the repository at this point in the history
Make sure that we scrub the time zone correctly for the line started with `---` as well.

This should keep the release PR a lot smaller and easier to review.
  • Loading branch information
sluongng committed Jun 6, 2022
1 parent 8a36282 commit e819d11
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions go/tools/releaser/upgradedep.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,17 @@ func parseUpgradeDepDirective(call *bzl.CallExpr) (orgName, repoName string, err
// that any year starting with "19" is a zero-valeud date.
func sanitizePatch(patch []byte) []byte {
lines := bytes.Split(patch, []byte{'\n'})
LineLoop:

for i, line := range lines {
if !bytes.HasPrefix(line, []byte("+++ ")) && !bytes.HasSuffix(line, []byte("--- ")) {
if !bytes.HasPrefix(line, []byte("+++ ")) && !bytes.HasPrefix(line, []byte("--- ")) {
continue
}

tab := bytes.LastIndexByte(line, '\t')
if tab < 0 || bytes.HasPrefix(line[tab+1:], []byte("19")) {
continue LineLoop
continue
}

lines[i] = append(line[:tab+1], []byte("2000-01-01 00:00:00.000000000 -0000")...)
}
return bytes.Join(lines, []byte{'\n'})
Expand Down

0 comments on commit e819d11

Please sign in to comment.