Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to run 'git describe' on a git repository without having to do a 'git clone' first? [duplicate]

Tags:

git

clone

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?

like image 481
kojiro Avatar asked Nov 20 '22 16:11

kojiro


1 Answers

#!/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
like image 114
Zombo Avatar answered Dec 26 '22 12:12

Zombo