Skip to content

Instantly share code, notes, and snippets.

@krdln
Created September 6, 2015 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krdln/11cdbcf2d3742d40ed7b to your computer and use it in GitHub Desktop.
Save krdln/11cdbcf2d3742d40ed7b to your computer and use it in GitHub Desktop.
#!/bin/bash
# rustdatehash: computes a git commit hash for a nightly from a given date.
# Works from about 2015-03-01
# usage: ./rustdatehash yyyy-mm-dd
set -e
set -u
set -o pipefail
# not using $1 in grep because the date in version string sometimes doesn't match the argument
wget -q -O - https://static.rust-lang.org/dist/$1/rust-nightly-i686-unknown-linux-gnu.tar.gz |\
gunzip -c |\
strings -n 10 |\
grep '([0-9a-z]\{5,\} 20[0-9][0-9]-[0-9][0-9]-[0-9][0-9])' -o |\
grep '[0-9a-z]\{5,\}*' -o |\
head -n 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment