Skip to content


Browse files Browse the repository at this point in the history
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
  • Loading branch information
codyoss committed Jan 5, 2021
1 parent 4f26875 commit 112ca94
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/gapicgen/generator/git.go
Expand Up @@ -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 {
Expand Down

0 comments on commit 112ca94

Please sign in to comment.