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

Unified Diff: client/cmd/isolate/exp_archive.go

Issue 2584323002: client/isolate: add --dump_json support to exparchive (Closed)
Patch Set: Created 4 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/isolate/exp_archive.go
diff --git a/client/cmd/isolate/exp_archive.go b/client/cmd/isolate/exp_archive.go
index 7db96e5fa1109789afe07a7bd9e600ae83853793..d58db6445e6a2817ad207b277e174fd1451159f7 100644
--- a/client/cmd/isolate/exp_archive.go
+++ b/client/cmd/isolate/exp_archive.go
@@ -13,6 +13,7 @@ import (
"log"
"os"
"path/filepath"
+ "strings"
"time"
@@ -49,6 +50,8 @@ var cmdExpArchive = &subcommands.Command{
c := &expArchiveRun{}
c.commonServerFlags.Init()
c.isolateFlags.Init(&c.Flags)
+ c.Flags.StringVar(&c.dumpJSON, "dump-json", "",
+ "Write isolated digests of archived trees to this file as JSON")
return c
},
}
@@ -58,6 +61,7 @@ var cmdExpArchive = &subcommands.Command{
type expArchiveRun struct {
commonServerFlags // Provides the GetFlags method.
isolateFlags isolateFlags
+ dumpJSON string
}
// Item represents a file or symlink referenced by an isolate file.
@@ -253,6 +257,25 @@ func (c *expArchiveRun) main() error {
}
fmt.Printf("%s\t%s\n", isolItem.Digest, filepath.Base(archiveOpts.Isolated))
+ // Optionally, write the digest of the isolated file as JSON (in the same
+ // format as batch_archive).
+ if c.dumpJSON != "" {
+ // The name is the base name of the isolated file, extension stripped.
+ name := filepath.Base(archiveOpts.Isolated)
+ if i := strings.LastIndex(name, "."); i != -1 {
+ name = name[:i]
+ }
+ j, err := json.Marshal(map[string]isolated.HexDigest{
+ name: isolItem.Digest,
+ })
+ if err != nil {
+ return err
+ }
+ if err := ioutil.WriteFile(c.dumpJSON, j, 0644); err != nil {
+ return err
+ }
+ }
+
end := time.Now()
if endpoint := eventlogEndpoint(c.isolateFlags.EventlogEndpoint); endpoint != "" {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698