From a2954a10d88716eeefeb00cdf3e34506fc40507d Mon Sep 17 00:00:00 2001 From: Son Luong Ngoc Date: Mon, 6 Jun 2022 16:40:32 +0200 Subject: [PATCH] releaser: fix scrubbing timestamp from patch files 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. --- go/tools/releaser/upgradedep.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/go/tools/releaser/upgradedep.go b/go/tools/releaser/upgradedep.go index 287c069b88..6e28c08ed9 100644 --- a/go/tools/releaser/upgradedep.go +++ b/go/tools/releaser/upgradedep.go @@ -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'})