Skip to content

Instantly share code, notes, and snippets.

@mridang
Created August 9, 2021 20:15
Show Gist options
  • Save mridang/c5bfde98456a6e5ec2246ae0481363f3 to your computer and use it in GitHub Desktop.
Save mridang/c5bfde98456a6e5ec2246ae0481363f3 to your computer and use it in GitHub Desktop.
#!/bin/sh
sha=$(shasum -b "$1" | awk '{print $1}')
url="https://search.maven.org/solrsearch/select?q=1:%22${sha}%22&rows=1&wt=json"
if curl -s -o json -L "$url"; then
gav=$(jq -r '.response.docs[0].g + ":" + .response.docs[0].a + ":" + .response.docs[0].v' json)
if [ "$gav" != "null" ]; then
cat gav
fi
rm -f json
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment