]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - fetch_version
5 echo "$0 [-n|--name name] [-b|--branch branch] [-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
75 function fetch_github
() {
76 rev="$(git ls-remote --refs $url refs/heads/$branch | head -n1 | cut -f1)"
77 sha
="$(nix-prefetch-url --unpack $url/archive/$branch.tar.gz)"
78 # Différent du git-describe et github-spécifique
79 #tag=$(echo "$awk_describe" | awk -f - $url | sed -e "s/^v//")
80 tag
=${rev:0:7}-$branch
83 function fetch_other
() {
84 rev="$(git ls-remote --refs $url refs/heads/$branch | head -n1 | cut -f1)"
85 sha
="$(nix-prefetch-git --url $url --rev refs/heads/$branch | jq -r '.sha256')"
86 tag
=${rev:0:7}-$branch
90 https
://*github.com
/*)
91 fetch_github
2>/dev
/null
92 owner
=$(echo "$url" | cut -d"/" -f4)
93 repo
=$(echo "$url" | cut -d"/" -f5)
107 "fetchSubmodules": true
112 fetch_other
2>/dev
/null
124 "fetchSubmodules": true
132 --arg owner
"$owner" \
137 --arg branch
"$branch" \