in linter/main.go [271:289]
func getFilesChanged(gitRoot string, pullBaseSha string, pullPullSha string) ([]string, []string, error) {
presubmitFiles := []string{}
postsubmitFiles := []string{}
gitDiffCommand := []string{"git", "-C", gitRoot, "diff", "--name-only", pullBaseSha, pullPullSha}
fmt.Println("\n", strings.Join(gitDiffCommand, " "))
gitDiffOutput, err := exec.Command("git", gitDiffCommand[1:]...).Output()
filesChanged := strings.Fields(string(gitDiffOutput))
for _, file := range filesChanged {
if strings.Contains(file, "presubmits") && strings.HasPrefix(file, "jobs") && strings.HasSuffix(file, "yaml") {
presubmitFiles = append(presubmitFiles, file)
}
if strings.Contains(file, "postsubmits") && strings.HasPrefix(file, "jobs") && strings.HasSuffix(file, "yaml") {
postsubmitFiles = append(postsubmitFiles, file)
}
}
return presubmitFiles, postsubmitFiles, err
}