From 307a4928479cb3ad030f0183cf25cd01c26b240a Mon Sep 17 00:00:00 2001 From: Brian Read Date: Wed, 19 Jul 2023 13:20:02 +0100 Subject: [PATCH] Update list-all-ord-repos to include all releases --- README.md | 21 +++++++++++++++++++++ git-list-all-org-repos.sh | 21 ++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a29657c..ed1fe22 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ Does: Create a release and upload the rpm (src and bin) as attachments to that release * \ repository (package) to be editted (e.g. smeserver-yum) +* \ create draft or prerelease else it will create full stable release * \ can be any organisation or user on the remote or local GITEA instance * \ will have "SME" added to the front of it (so e.g. 10.2 -> SME10.2) @@ -149,3 +150,23 @@ Does: Create the release (deleting one that is the same tag), Then uploads the .src.rpm and .rpm as an attachment (deleting any one of the same name) +## git-list-all-org-repos.sh +List the repos in any one organisation and optionally show the release and some associated fields + +* \ can be any organisation or user on the remote or local GITEA instance + +optional: (in any order) + +* \ used with org= and will use local GITEA instance, default remote - will be passed to \ +* \ show line being executed +* \ run in debug mode +* \ Show all draft releases +* \ Show all prereleases +* \ Show all full releases +* \ Show all releases +* \ Show the url to use to clone this repo +* \ Show the url to get the zipped contents of the repo + +Does: + +Display a "table" of each repo and the optional extras requested. diff --git a/git-list-all-org-repos.sh b/git-list-all-org-repos.sh index c8a7eed..51fd264 100755 --- a/git-list-all-org-repos.sh +++ b/git-list-all-org-repos.sh @@ -55,7 +55,7 @@ for param in $2 $3 $4 $5 $6 $7 $8 $9 $10; do prerelease ) SHOWRELEASE=true;SHOWPRERELEASE=true;SHOWDRAFT=false ;; allreleases ) - SHOWRELEASE=true;SHOWPRERELEASE=true;SHOWDRAFT=true ;; + SHOWRELEASE=true;SHOWALLRELEASES=true ;; cloneurl ) SHOWCLONEURL=true ;; zipurl ) @@ -90,22 +90,29 @@ done REPO_LIST=$(echo $REPO_LIST | tr -s '[:space:]' '\n' | sort) for item in $REPO_LIST ; do line=$item - if [[ $SHOWID || $SHOWRELEASE || $SHOWCLONEURL || $ZIPURL ]] ; then + if [[ $SHOWID || $SHOWRELEASE || $SHOWCLONEURL || $ZIPURL || $SHOWALLRELEASES ]] ; then #Find and show releases # echo "$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases?draft=true&pre-release=true&limit=100" \ # -H 'accept: application/json' \ # -H "Authorization: token $GITEAACCESSTOKEN" - RESPONSE=$(curl -s -X 'GET' \ - "$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases?draft=$SHOWDRAFT&pre-release=SHOWPRERELEASE&limit=100" \ - -H 'accept: application/json' \ - -H "Authorization: token $GITEAACCESSTOKEN") + if [ $SHOWALLRELEASES ] ; then + RESPONSE=$(curl -s -X 'GET' \ + "$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases" \ + -H 'accept: application/json' \ + -H "Authorization: token $GITEAACCESSTOKEN"); + else + RESPONSE=$(curl -s -X 'GET' \ + "$GITEAHOST/api/v1/repos/$ORG_NAME/$item/releases?draft=$SHOWDRAFT&pre-release=$SHOWPRERELEASE&limit=100" \ + -H 'accept: application/json' \ + -H "Authorization: token $GITEAACCESSTOKEN"); + fi if [ $DEBUG ] ; then echo "$RESPONSE"; fi if [ $SHOWRELEASE ] ; then # Will need to use " jq 'map(.name)'" once we have more than one release. REL=$(echo $RESPONSE | jq -r '.[0].tag_name') ID=$(echo $RESPONSE | jq -r '.[0].id') if [ $DEBUG ] ; then echo $REL; fi - if [ "$REL" ] ; then line="$line\t$REL($ID)"; + if [ "$REL" ] ; then line="$line\t\t\t$REL($ID)"; else line="$line\tnone";fi if [ $SHOWCLONEURL ] ; then URL=$(echo $RESPONSE | jq -r '.[0].url')