From 56969eff408f71026a6006f0f1705a0e2000b888 Mon Sep 17 00:00:00 2001 From: Brian Read Date: Fri, 2 Jun 2023 14:26:42 +0100 Subject: [PATCH] Add post create frm template script --- git-post-create-repo.sh | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 git-post-create-repo.sh diff --git a/git-post-create-repo.sh b/git-post-create-repo.sh new file mode 100755 index 0000000..955523f --- /dev/null +++ b/git-post-create-repo.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# +# Fiddle with the newly created repo to fix things that cannot be done throug the gitea template +# +# $1 = Module name e.g. smeserver-null +# $2 = Organisation (smeserver or smecontrib)e +# $3 = "local" will use parameters set for local repository else it will use remote +# +if [[ -z $1 ]] ; then + echo "************git-post-create-repo.sh []" + exit 0 +fi + + +# +# Pull in parameters from a config file ~/.smegit/config +# +inifilename=$(echo ~)"/.smegit/config" +if [ ! -e $inifilename ] ; then + # Not here, look at system default + if [ ! -e /etc/smegit.ini ] ; then + echo "No ini file found $inifiename or /etc/smegit.ini" + echo "*git-post-create-repo.sh []" + exit 1 + else + initfilename="/etc/smegit.ini" + fi +fi + +while read -r line || [[ -n "$line" ]]; do + if [[ $line =~ ^\[.*\]$ ]] + then + section=${line#*[} + section=${section%]*} + else + if [[ $line =~ ^[^#]*= ]] + then + key=${line%=*} + value=${line#*=} + declare "${section}_${key}=$value" + fi + fi +done < "$inifilename" + +LOCALUser=${local_USER} +if [[ $smegit_WORKDIR == ~* ]] ; then + # relative to users home dir + WORKDIR=$(echo ~)${smegit_WORKDIR:1} +else + # absolute path + WORKDIR=${smegit_WORKDIR} +fi +if [ $DEBUG ] ; then echo "WORKDIR=$WORKDIR" ; fi +GITEAUser=$remote_USER +GITEAACCESSTOKEN=$remote_GITEAACCESSTOKEN +GITEAHOST=$remote_GITEAHOST +if [ $3 ] ; then +if [ "$3" == "local" ] ; then + GITEAUser=$local_USER + GITEAACCESSTOKEN=$local_GITEAACCESSTOKEN + GITEAHOST=$local_GITEAHOST +fi +fi +RemoteRepoURL="$GITEAHOST/$2/$1" +cd $WORKDIR/$2/$1 +echo `pwd` + +# Rename the spec file accordingly to $1 +mv change-this-to-the-package-name.spec $1.spec + +# Set the date in the spec file changelog to today +dateH=`date "+%a %b %d %Y"` +sed -i "s/Day MMMM DD YYYY/$dateH/" $1.spec + +#Now write them all back to the repo + +git add -A +git status +git commit -m "post create changes" +git push + +# and fix up the external links to the Wiki and the Issues +# (this is a bug that I have logged) - they say is not supported. + +TARGETPKG=$1 +if [[ "$2" == "smecontribs" ]]; then + BASEORCONTRIB="contribs10" + PRODUCTBUGZILLA="SME%20Contribs" +else + BASEORCONTRIB="sme10" + PRODUCTBUGZILLA="SME%20Server%2010.X" +fi +TARGETORG=brianr +PRODUCTBUGZILLA= +WIKILINK="https://wiki.koozali.org" +RESPONSE=$(curl -X 'PATCH' \ + "$GITEAHOST/api/v1/repos/$TARGETORG/$TARGETPKG" \ + -H 'accept: application/json' \ + -H "Authorization: token $GITEAACCESSTOKEN" \ + -H 'Content-Type: application/json' \ + -d '{ + "description": "'"SMEServer Koozali developed repo for $TARGETPKG base"'", + "has_issues": true, + "external_tracker": { + "external_tracker_format": "https://bugs.koozali.org/show_bug.cgi?id={index}", + "external_tracker_style": "numeric", + "external_tracker_url": "'"https://bugs.koozali.org/buglist.cgi?component=$TARGETPKG&product=$PRODUCTBUGZILLA"'" + }, + "has_wiki": true, + "external_wiki": { + "external_wiki_url": "'"$WIKILINK"'" + } + }' + ) +echo $RESPONSE + +#That's All for now folks!! +exit 0 + + + + + + + +