85 lines
2.1 KiB
Bash
85 lines
2.1 KiB
Bash
|
#!/bin/bash
|
||
|
#
|
||
|
# git-delete-release-in-one-rep.sh <organisation> <repo> [ <releasetag> | <id> ]
|
||
|
#
|
||
|
# 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)
|
||
|
#
|
||
|
#
|
||
|
if [[ -z $1 ]] ; then
|
||
|
echo "git-delete-release-in-one-rep.sh <organisation> <repo> <organisation> <repo> [ <releasetag> | <id> ] [local] [debug]"
|
||
|
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-delete-release-in-one-rep.sh <organisation> <repo> <organisation> <repo> [ <releasetag> | <id> ] [local] [debug]"
|
||
|
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"
|
||
|
|
||
|
DEBUG=
|
||
|
if [ ${smegit_DEBUG} == "true" ] ; then DEBUG=true ; fi
|
||
|
GITEAUser=${remote_USER}
|
||
|
GITEAACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||
|
GITEAHOST=${remote_GITEAHOST}
|
||
|
for param in $2 $3 $4 $5 $6 $7; do
|
||
|
if [ $param ] ; then
|
||
|
case $param in
|
||
|
local )
|
||
|
GITEAUser=${local_USER}
|
||
|
GITEAACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||
|
GITEAHOST=${local_GITEAHOST}
|
||
|
;;
|
||
|
debug )
|
||
|
DEBUG=true ;;
|
||
|
* )
|
||
|
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||
|
esac
|
||
|
else
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
# Uses if ist char is numeric to see if an id or tag is provided
|
||
|
if [[ ! "${3:0:1}" =~ [0-9] ]]; then
|
||
|
# <organisation> <repo> <releasetag> - find the id from the info provided
|
||
|
ID=999;
|
||
|
# TBD
|
||
|
else
|
||
|
ID=$3;
|
||
|
fi
|
||
|
|
||
|
if [ $DEBUG ]; then echo "I:$ID"; fi
|
||
|
|
||
|
# And then delete it by id.
|
||
|
RESPONSE=$(curl -s -X 'DELETE' \
|
||
|
"$GITEAHOST/api/v1/repos/$2/$1/releases/$ID" \
|
||
|
-H 'accept: application/json' \
|
||
|
-H "Authorization: token $GITEAACCESSTOKEN")
|
||
|
if [ $DEBUG ]; then echo "$RESPONSE"; fi
|
||
|
exit 0
|