Skip to content

Instantly share code, notes, and snippets.

@prateek
Last active September 29, 2018 04:06
Show Gist options
  • Save prateek/0ff5dc3fabbda68f7c0c0c3d56368a67 to your computer and use it in GitHub Desktop.
Save prateek/0ff5dc3fabbda68f7c0c0c3d56368a67 to your computer and use it in GitHub Desktop.
Generate diff-able summaries for glide.{yaml|lock} and Gopkg.{toml|lock} file
#!/bin/bash
# requires https://github.com/dbohdan/remarshal
# generate diff summary for .lock file
cat <(cat glide.lock| yaml2json -i - -o - | jq -r '.imports[] | .name + " " + .version') \
<(cat glide.lock| yaml2json -i - -o - | jq -r '.testImports[] | .name + " " + .version') \
| sort | uniq > glide.lock.summary
cat Gopkg.lock | toml2json -i - -o - | jq -r '.projects[] | .revision + " " + .name' \
| sort | uniq > Gopkg.lock.summary
# generate diff summary for glide.yaml & Gopkg.toml file
cat <(cat glide.yaml | yaml2json -i - -o - | jq -r '.import[] | (.package + " " + (.version|tostring))') \
<(cat glide.yaml| yaml2json -i - -o - | jq -r '.testImport[] | .package + " " + .version +.revision') \
| sort | uniq > glide.yaml.summary
cat Gopkg.toml | toml2json -i - -o - | jq -r '.constraint[] | .name + " " + .version' \
| sort | uniq > Gopkg.toml.summary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment