cmd/vulnreport: use pattern for add/commit in vulnreport commit
Instead of searching for specific derived files to add/commit,
use the pattern "*<Go ID>*" to add/commit all files mentioning the
current Go ID. This will allow commit to work when "unexcluding" a report.
Change-Id: I22f8b91b1fc5f0255db26b9b05d680578817c899
Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/569596
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/vulnreport/commit.go b/cmd/vulnreport/commit.go
index 1904eab..4ac21d6 100644
--- a/cmd/vulnreport/commit.go
+++ b/cmd/vulnreport/commit.go
@@ -57,17 +57,9 @@
return fmt.Errorf("file %q has unaddressed %q fields", filename, "TODO:")
}
- // Find all derived files (OSV and CVE).
- files := []string{filename}
- if r.Excluded == "" {
- files = append(files, r.OSVFilename())
- }
- if r.CVEMetadata != nil {
- files = append(files, r.CVEFilename())
- }
-
- // Add the files to git.
- if err := gitAdd(files...); err != nil {
+ // Add all the files related to this report.
+ glob := fmt.Sprintf("*%s*", r.ID)
+ if err := gitAdd(glob); err != nil {
return err
}
@@ -76,7 +68,7 @@
if err != nil {
return err
}
- return gitCommit(msg, files...)
+ return gitCommit(msg, glob)
}
func newCommitMsg(r *report.Report) (string, error) {