-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/database: (no-op) split load and generate files
Move Diff function into its own file, and move code and tests related to OSV generation into their own file. For golang/go#56417 Change-Id: Ia41b3f9068efe543c1a603c34738810c404e6caf Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/448840 Run-TryBot: Tatiana Bradley <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
- Loading branch information
Showing
6 changed files
with
429 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2022 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package database | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
"golang.org/x/vulndb/internal/derrors" | ||
) | ||
|
||
func Diff(dbname1, dbname2 string) (err error) { | ||
defer derrors.Wrap(&err, "Diff(%q, %q)", dbname1, dbname2) | ||
indexA, dbA, err := Load(dbname1) | ||
if err != nil { | ||
return fmt.Errorf("unable to load %q: %s", dbname1, err) | ||
} | ||
indexB, dbB, err := Load(dbname2) | ||
if err != nil { | ||
return fmt.Errorf("unable to load %q: %s", dbname2, err) | ||
} | ||
indexDiff := cmp.Diff(indexA, indexB) | ||
if indexDiff == "" { | ||
indexDiff = "(no change)" | ||
} | ||
dbDiff := cmp.Diff(dbA, dbB) | ||
if dbDiff == "" { | ||
dbDiff = "(no change)" | ||
} | ||
fmt.Printf("# index\n%s\n\n# db\n%s\n", indexDiff, dbDiff) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.