From 2aa099f0e2c3f6932b69c492f8691e17eb552397 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 31 Mar 2021 16:38:58 +0200 Subject: [PATCH] sh: add script to build the gitTable --- garlic/sh/default.nix | 1 + garlic/sh/garlic-git-table | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 garlic/sh/garlic-git-table diff --git a/garlic/sh/default.nix b/garlic/sh/default.nix index 0a5189d..8d5c6f9 100644 --- a/garlic/sh/default.nix +++ b/garlic/sh/default.nix @@ -34,5 +34,6 @@ in chmod +x $out/bin/garlic mkdir -p $out/share/man/man1 cp garlic.1 $out/share/man/man1 + cp garlic-git-table $out/bin ''; } diff --git a/garlic/sh/garlic-git-table b/garlic/sh/garlic-git-table new file mode 100755 index 0000000..8d33e7b --- /dev/null +++ b/garlic/sh/garlic-git-table @@ -0,0 +1,25 @@ +#!/bin/sh + +progname="$(basename $0)" + +if [ -z "$1" ]; then + cat >&2 < + +Finds all garlic/* branches and their current commit of the given +repository and builds the gitTable to be used in nix derivations. + +Example: + garlic-git-table ssh://git@bscpm03.bsc.es/garlic/apps/heat.git +EOF + exit 1 +fi + +echo 'gitTable = {' +echo " # Auto-generated with $progname on $(date --rfc-3339=date)" +git ls-remote $1 'garlic/*' |\ + sed 's@refs/heads/@@' |\ + awk '{printf "\"%s\" = \"%s\";\n", $2, $1}' |\ + column -t -o ' ' |\ + sed 's/^/ /' +echo '};'