From 112ca9416cc8a2502b32547dc8d789655452f84a Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Tue, 5 Jan 2021 12:36:48 -0700 Subject: [PATCH] fix(internal/gapicgen): don't regen files that have been deleted (#3471) Currently this method will find all the files that haven been updated since the last hash. This is then used to find out which packages will need to be regenerated. We should not try to regenerate files that have been deleted, this causes a file does not exist error when running the generator. The provided flag restricts to files that: - (A) Added - (C) Copied - (M) Modified - (R) Renamed --- internal/gapicgen/generator/git.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/gapicgen/generator/git.go b/internal/gapicgen/generator/git.go index 0e7faa4ed88..189bad5d816 100644 --- a/internal/gapicgen/generator/git.go +++ b/internal/gapicgen/generator/git.go @@ -134,7 +134,12 @@ func CommitsSinceHash(gitDir, hash string, inclusive bool) ([]string, error) { // hash for the given gitDir. func UpdateFilesSinceHash(gitDir, hash string) ([]string, error) { out := bytes.NewBuffer(nil) - c := command("git", "diff-tree", "--no-commit-id", "--name-only", "-r", fmt.Sprintf("%s..HEAD", hash)) + // The provided diff-filter flags restricts to files that have been: + // - (A) Added + // - (C) Copied + // - (M) Modified + // - (R) Renamed + c := command("git", "diff-tree", "--no-commit-id", "--name-only", "--diff-filter=ACMR", "-r", fmt.Sprintf("%s..HEAD", hash)) c.Stdout = out c.Dir = gitDir if err := c.Run(); err != nil {