Skip to content
Browse files
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 112ca9416cc8a2502b32547dc8d789655452f84a
Showing with 6 additions and 1 deletion.
  1. +6 −1 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 {

0 comments on commit 112ca94

Please sign in to comment.