Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
587 views
in Technique[技术] by (71.8m points)

clone - Is there a simple way to "git describe" a remote repository?

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

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

The problem is I don't know what $tag is. It should be the output of git describe --abbrev=0 on an up-to-date clone, but I don't know how to get that information without making a local clone of the repository. Is it possible to do this without making a local clone?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
#!/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
" : "%s
", tag, com, sha
}

Sample output

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...