add in smegit/config processing
This commit is contained in:
parent
7fb53cc776
commit
255cce967a
@ -5,20 +5,52 @@
|
||||
if [[ -z $1 ]] ; then
|
||||
echo "parse a list of parameters and execute script with those parameters"
|
||||
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 "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 " <noisy> show line being executed"
|
||||
echo " <additional> additional params to be passed (up to 3)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $(which $2 | grep "no $2") ]] ; then
|
||||
echo "Can NOT find $2 - Aborting"
|
||||
@ -27,8 +59,9 @@ fi
|
||||
|
||||
REVIEW=
|
||||
NOISY=
|
||||
PROCESSORG=
|
||||
EXTRAPARAMS=
|
||||
GITEAHOST=${remote_GITEAHOST}
|
||||
ACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||
for param in $3 $4 $5 $6; do
|
||||
if [ $param ] ; then
|
||||
case $param in
|
||||
@ -36,8 +69,9 @@ for param in $3 $4 $5 $6; do
|
||||
REVIEW=true ;;
|
||||
noisy )
|
||||
NOISY=true ;;
|
||||
org=* )
|
||||
PROCESSORG=${$param#*=}
|
||||
local )
|
||||
GITEAHOST=${local_GITEAHOST}
|
||||
ACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||
;;
|
||||
* )
|
||||
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||||
@ -51,9 +85,9 @@ if [ $PROCESSORG ] ; then
|
||||
# cycle through the repos in the specified organisation
|
||||
# get a list of repositories in the source organisation
|
||||
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' \
|
||||
"$GITEAHOST/api/v1/orgs/$1/repos?page=$page" \
|
||||
"$GITEAHOST/api/v1/orgs/$PROCESSORG/repos?page=$page" \
|
||||
-H 'accept: application/json' \
|
||||
-H "Authorization: token $ACCESSTOKEN"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user