Skip to content

Commit 112ca94

Browse files
authored
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
1 parent 4f26875 commit 112ca94

File tree

1 file changed

+6
-1
lines changed
  • internal/gapicgen/generator

1 file changed

+6
-1
lines changed

internal/gapicgen/generator/git.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ func CommitsSinceHash(gitDir, hash string, inclusive bool) ([]string, error) {
134134
// hash for the given gitDir.
135135
func UpdateFilesSinceHash(gitDir, hash string) ([]string, error) {
136136
out := bytes.NewBuffer(nil)
137-
c := command("git", "diff-tree", "--no-commit-id", "--name-only", "-r", fmt.Sprintf("%s..HEAD", hash))
137+
// The provided diff-filter flags restricts to files that have been:
138+
// - (A) Added
139+
// - (C) Copied
140+
// - (M) Modified
141+
// - (R) Renamed
142+
c := command("git", "diff-tree", "--no-commit-id", "--name-only", "--diff-filter=ACMR", "-r", fmt.Sprintf("%s..HEAD", hash))
138143
c.Stdout = out
139144
c.Dir = gitDir
140145
if err := c.Run(); err != nil {

0 commit comments

Comments
 (0)