osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/34816?usp=email )
Change subject: scripts/common: osmo_git_last_commit…: add vars ......................................................................
scripts/common: osmo_git_last_commit…: add vars
Add variable names for $1, $2, $3 so the logic is easier to follow.
Related: OS#6227 Change-Id: I7abbcefc8d5bd4c5b84c30a7e38ca3dcb855dd56 --- M scripts/common.sh 1 file changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/16/34816/1
diff --git a/scripts/common.sh b/scripts/common.sh index 72be4fc..8099499 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -74,19 +74,23 @@ # ee618ecbedec82dfd240334bc87d0d1c806477b0 refs/tags/debian/0.9.13-0_jrsantos.1 # a3fdd24af099b449c9856422eb099fb45a5595df refs/tags/debian/0.9.13-0_jrsantos.1^{} # ... + local project="$1" + local amount="$2" + local default_str="$3" local url ret - url="$(osmo_git_clone_url "$1")" + + url="$(osmo_git_clone_url "$project")" ret="$(git ls-remote --tags "$url")" ret="$(echo "$ret" | grep 'refs/tags/[0-9.]*$' || true)" ret="$(echo "$ret" | sort -V -t/ -k3)" - if [ "$2" != "all" ]; then - ret="$(echo "$ret" | tail -n "$2")" + if [ "$amount" != "all" ]; then + ret="$(echo "$ret" | tail -n "$amount")" fi
if [ -n "$ret" ]; then echo "$ret" else - echo "$3" + echo "$default_str" fi }