add in smegit/config processing
This commit is contained in:
parent
7fb53cc776
commit
255cce967a
@ -5,19 +5,51 @@
|
|||||||
if [[ -z $1 ]] ; then
|
if [[ -z $1 ]] ; then
|
||||||
echo "parse a list of parameters and execute script with those parameters"
|
echo "parse a list of parameters and execute script with those parameters"
|
||||||
echo "parse-list.sh <param file> <script> [<noisy> <additional> <additional> <additional>]"
|
echo "parse-list.sh <param file> <script> [<noisy> <additional> <additional> <additional>]"
|
||||||
echo "<param file> = name of file containing parameters"
|
echo "<param file|org='organisation'> name of file containing parameters"
|
||||||
|
echo " or the organisation list of repos"
|
||||||
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
|
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
|
||||||
echo "optional params can appear in any order"
|
echo "optional params can appear in any order"
|
||||||
echo " <org='organisation'> run for each repo in 'organisation' (e.g. org=smeserver)"
|
|
||||||
echo " <review> show line being executed but do NOTHING!"
|
echo " <review> show line being executed but do NOTHING!"
|
||||||
echo " <noisy> show line being executed"
|
echo " <noisy> show line being executed"
|
||||||
echo " <additional> additional params to be passed (up to 3)"
|
echo " <additional> additional params to be passed (up to 3)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f $1 ]] ; then
|
# parse the command line parameters
|
||||||
|
PROCESSORG=
|
||||||
|
if [[ $1 == "org=*" ]] ; then
|
||||||
|
# using a list of the repos in this organisatoin as input
|
||||||
|
PROCESSORG=${$param#*=}
|
||||||
|
# Get the ini file and relevant parameters - only needed for org processing
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
else
|
||||||
|
# using a file as input
|
||||||
|
if [[ ! -f $1 ]] ; then
|
||||||
echo "Can NOT find $1 - Aborting"
|
echo "Can NOT find $1 - Aborting"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(which $2 | grep "no $2") ]] ; then
|
if [[ $(which $2 | grep "no $2") ]] ; then
|
||||||
@ -27,8 +59,9 @@ fi
|
|||||||
|
|
||||||
REVIEW=
|
REVIEW=
|
||||||
NOISY=
|
NOISY=
|
||||||
PROCESSORG=
|
|
||||||
EXTRAPARAMS=
|
EXTRAPARAMS=
|
||||||
|
GITEAHOST=${remote_GITEAHOST}
|
||||||
|
ACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||||
for param in $3 $4 $5 $6; do
|
for param in $3 $4 $5 $6; do
|
||||||
if [ $param ] ; then
|
if [ $param ] ; then
|
||||||
case $param in
|
case $param in
|
||||||
@ -36,9 +69,10 @@ for param in $3 $4 $5 $6; do
|
|||||||
REVIEW=true ;;
|
REVIEW=true ;;
|
||||||
noisy )
|
noisy )
|
||||||
NOISY=true ;;
|
NOISY=true ;;
|
||||||
org=* )
|
local )
|
||||||
PROCESSORG=${$param#*=}
|
GITEAHOST=${local_GITEAHOST}
|
||||||
;;
|
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||||
|
;;
|
||||||
* )
|
* )
|
||||||
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||||||
esac
|
esac
|
||||||
@ -51,9 +85,9 @@ if [ $PROCESSORG ] ; then
|
|||||||
# cycle through the repos in the specified organisation
|
# cycle through the repos in the specified organisation
|
||||||
# get a list of repositories in the source organisation
|
# get a list of repositories in the source organisation
|
||||||
for page in {1..10} ; do
|
for page in {1..10} ; do
|
||||||
if [ $DEBUG ] ; then echo "getting page $page of repos from $GITHOST $1" ; fi
|
if [ $DEBUG ] ; then echo "getting page $page of repos from $GITHOST $PROCESSORG" ; fi
|
||||||
RESPONSE=$(curl $curlsilent -X 'GET' \
|
RESPONSE=$(curl $curlsilent -X 'GET' \
|
||||||
"$GITEAHOST/api/v1/orgs/$1/repos?page=$page" \
|
"$GITEAHOST/api/v1/orgs/$PROCESSORG/repos?page=$page" \
|
||||||
-H 'accept: application/json' \
|
-H 'accept: application/json' \
|
||||||
-H "Authorization: token $ACCESSTOKEN"
|
-H "Authorization: token $ACCESSTOKEN"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user