]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - fetch_version
5 echo "$0 [-n|--name name] [-b|--branch branch_or_rev] [-f|--file out_file] [-h|--help] (-u|--url) url"
10 while [[ $# -gt 0 ]]; do
17 name
="$(echo "$content" | jq -r ".meta.name")"
18 url
="$(echo "$content" | jq -r ".meta.url")"
19 branch
="$(echo "$content" | jq -r ".meta.branch")"
43 if [ -z "$url" ]; then
46 if [ -z "$name" ]; then
47 name
=$(echo "$url" | cut -d"/" -f5)
49 if [ -z "$file" ]; then
53 # function fetch_ledger () {
54 # pushd $HOME/projets/ledger >/dev/null 2>/dev/null
56 # tag="$(git describe origin/next | sed -e "s/^v//")"
57 # rev="$(git show-ref -s refs/remotes/origin/next)"
58 # sha="$(nix-prefetch-url --unpack file://<(git archive --format=tar.gz HEAD) 2>/dev/null)"
59 # popd >/dev/null 2>/dev/null
62 # awk_describe='BEGIN {
64 # while ("git ls-remote " ARGV[1] "| sort -Vk2" | getline) {
66 # sha = substr($0, 1, 7)
69 # while ("curl -s " ARGV[1] "/releases/tag/" tag | getline)
72 # printf com ? "%s-%s-g%s\n" : "%s\n", tag, com, sha
86 function get_name
() {
93 b
="${branch#refs/tags/}"
97 b
=${branch#refs/heads/}
98 echo "$minirev-${b//\//-}"
102 echo "$minirev-${b//\//-}"
105 echo "$minirev-${branch//\//-}"
110 function fetch_github
() {
111 rev="$(git ls-remote --refs $url $(get_ref $branch) | head -n1 | cut -f1)"
112 sha
="$(nix-prefetch-url --unpack $url/archive/$rev.tar.gz)"
113 # Différent du git-describe et github-spécifique
114 #tag=$(echo "$awk_describe" | awk -f - $url | sed -e "s/^v//")
115 tag
=$(get_name $branch $rev)
118 function fetch_other
() {
119 rev="$(git ls-remote --refs $url $(get_ref $branch) | head -n1 | cut -f1)"
120 sha
="$(nix-prefetch-git --url $url --rev $(get_ref $branch) | jq -r '.sha256')"
121 tag
=$(get_name $branch $rev)
125 https
://*github.com
/*)
126 fetch_github
2>/dev
/null
127 owner
=$(echo "$url" | cut -d"/" -f4)
128 repo
=$(echo "$url" | cut -d"/" -f5)
142 "fetchSubmodules": true
147 fetch_other
2>/dev
/null
159 "fetchSubmodules": true
167 --arg owner
"$owner" \
172 --arg branch
"$branch" \