Is there a simple way to “git describe” a remote repository?

后端 未结 2 1296
迷失自我
迷失自我 2020-12-16 20:20

I want to execute the following command on a remote server:

git archive --prefix=\"$tag/\" --remote=\"ssh://$gitserver/var/git/$repo\" \"$tag\" | tar -xvf-
<         


        
2条回答
  •  醉话见心
    2020-12-16 20:47

    #!/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
    }
    

    Sample output

    $ git-describe-remote.awk https://github.com/stedolan/jq
    jq-1.4-148-g89791a0
    

提交回复
热议问题