Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Unified Diff: vpython/spec/spec.go

Issue 2864423002: vpython: Leave "pip" and related tools. (Closed)
Patch Set: fix word Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | vpython/spec/spec_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vpython/spec/spec.go
diff --git a/vpython/spec/spec.go b/vpython/spec/spec.go
index a0ed572cce7a092be3a69574611220deff207338..c0446f738c94022b6676c6b01254e83d654f3d44 100644
--- a/vpython/spec/spec.go
+++ b/vpython/spec/spec.go
@@ -45,7 +45,10 @@ func Normalize(spec *vpython.Spec, defaultVENVPackage *vpython.Spec_Package) err
// Hash hashes the contents of the supplied "spec" and returns the result as
// a hex-encoded string.
-func Hash(spec *vpython.Spec) string {
+//
+// If not empty, the contents of extra are prefixed to hash string. This can
+// be used to factor additional influences into the spec hash.
+func Hash(spec *vpython.Spec, extra string) string {
data, err := proto.Marshal(spec)
if err != nil {
panic(fmt.Errorf("failed to marshal proto: %v", err))
@@ -58,6 +61,9 @@ func Hash(spec *vpython.Spec) string {
}
hash := sha256.New()
+ if extra != "" {
+ mustWrite(fmt.Fprintf(hash, "%s:", extra))
+ }
mustWrite(fmt.Fprintf(hash, "%s:", vpython.Version))
mustWrite(hash.Write(data))
return hex.EncodeToString(hash.Sum(nil))
« no previous file with comments | « no previous file | vpython/spec/spec_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698