#!/usr/bin/awk -f
BEGIN {
  FS = "[ /^]+"
  while (("git ls-remote " ARGV[1] "| sort -Vk2") | getline) {
    if (!sha)
      sha = substr($0, 1, 7)
    tag = $3
  }
  while (("curl -s " ARGV[1] "/releases/tag/" tag) | getline)
    if ($3 ~ "commits")
      com = $2
  printf com ? "%s-%s-g%s\n" : "%s\n", tag, com, sha
}
