From: George Dunlap Date: Fri, 8 Dec 2017 14:58:01 +0000 (+0000) Subject: xsa: Add 'canonicalize' command X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=186012c7e8861bbabd9b9c59feb6f53a92d56b9f;p=people%2Fgdunlap%2Fxsatool xsa: Add 'canonicalize' command Canonicalize will simply read the metadata file and write it out again. This may be useful after editing it by hand or with external JSON tools, to put it back in "golang canonical" form. Signed-off-by: George Dunlap --- diff --git a/README.md b/README.md index 97b3584..e1d3a24 100644 --- a/README.md +++ b/README.md @@ -374,6 +374,15 @@ longer supported. (Eventually this will be implemented by the `xsatool global end-support [version]` command.) +## 'Canonicalizing' metadata files + +After editing metadata files by hand or with other JSON-parsing tools, +the order of fields may be signicantly different. You can run + +`xsatool NNN canonicalize` + +to reformat a file according to Golang's default format. + # Potential future functionality ## Automatically de-duplicating patches diff --git a/main.go b/main.go index ba59bfc..e01b5cd 100644 --- a/main.go +++ b/main.go @@ -140,6 +140,8 @@ func XsaMain(args []string) int { checkXSARepos = false case "dedup-patches": main = MainDedupPatches + case "canonicalize": + main = MainCanonicalize default: fmt.Printf("Unknown command: %s\n", cmd) return 1 diff --git a/xsa.go b/xsa.go index 0e55968..a1a217f 100644 --- a/xsa.go +++ b/xsa.go @@ -460,3 +460,11 @@ func MainDedupPatches(xsa *XSAMeta, args []string) (ret int) { return 0 } + +func MainCanonicalize(xsa *XSAMeta, args []string) (ret int) { + xsa.dirty = true + + xsa.Save() + + return 0 +}