]>
git.immae.eu Git - perso/Immae/Config/Nix/NUR.git/blob - scripts/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")"
42 if [ -z "$url" ]; then
45 if [ -z "$name" ]; then
46 name
=$(echo "$url" | cut -d"/" -f5)
48 if [ -z "$file" ]; then
52 # function fetch_ledger () {
53 # pushd $HOME/projets/ledger >/dev/null 2>/dev/null
55 # tag="$(git describe origin/next | sed -e "s/^v//")"
56 # rev="$(git show-ref -s refs/remotes/origin/next)"
57 # sha="$(nix-prefetch-url --unpack file://<(git archive --format=tar.gz HEAD) 2>/dev/null)"
58 # popd >/dev/null 2>/dev/null
61 # awk_describe='BEGIN {
63 # while ("git ls-remote " ARGV[1] "| sort -Vk2" | getline) {
65 # sha = substr($0, 1, 7)
68 # while ("curl -s " ARGV[1] "/releases/tag/" tag | getline)
71 # printf com ? "%s-%s-g%s\n" : "%s\n", tag, com, sha
85 function get_name
() {
92 b
="${branch#refs/tags/}"
96 b
=${branch#refs/heads/}
97 echo "$minirev-${b//\//-}"
101 echo "$minirev-${b//\//-}"
104 echo "$minirev-${branch//\//-}"
109 function fetch_github
() {
110 rev="$(git ls-remote --refs $url $(get_ref $branch) | head -n1 | cut -f1)"
111 sha
="$(nix-prefetch-url --unpack $url/archive/$rev.tar.gz)"
112 # Différent du git-describe et github-spécifique
113 #tag=$(echo "$awk_describe" | awk -f - $url | sed -e "s/^v//")
114 tag
=$(get_name $branch $rev)
117 function fetch_other
() {
118 rev="$(git ls-remote --refs $url $(get_ref $branch) | head -n1 | cut -f1)"
119 sha
="$(nix-prefetch-git --url $url --rev $(get_ref $branch) | jq -r '.sha256')"
120 tag
=$(get_name $branch $rev)
124 https
://*github.com
/*)
125 fetch_github
2>/dev
/null
126 owner
=$(echo "$url" | cut -d"/" -f4)
127 repo
=$(echo "$url" | cut -d"/" -f5)
141 "fetchSubmodules": true
146 fetch_other
2>/dev
/null
158 "fetchSubmodules": true
166 --arg owner
"$owner" \
171 --arg branch
"$branch" \