add system default ini and allow ~ in workdir
This commit is contained in:
parent
3d62c04c19
commit
2edef6eb76
@ -9,25 +9,29 @@
|
||||
#
|
||||
|
||||
if [[ -z $1 ]] ; then
|
||||
echo "************git_cvs2git.sh <modulename> <organization> [<local>]"
|
||||
echo "************git-cvs2git.sh <modulename> <organization> [<local>]"
|
||||
exit 0
|
||||
fi
|
||||
clear
|
||||
echo "**************************************************************************************************"
|
||||
echo "* *"
|
||||
echo "* SMEServer - git_cvs2git $1 $2 $3 `date` *"
|
||||
echo "* SMEServer - git-cvs2git $1 $2 $3 `date` *"
|
||||
echo "* *"
|
||||
echo "**************************************************************************************************"
|
||||
|
||||
#
|
||||
# Pull in parameters from a config file ~/.smegit/config
|
||||
#
|
||||
#inifilename=$(find ~/GITFiles -name cvs2git.ini 2>/dev/null | head -n 1)
|
||||
inifilename=$(echo ~)"/.smegit/config"
|
||||
if [ ! -e $inifilename ] ; then
|
||||
# Not here
|
||||
echo "ERROR*******No ini file found $inifilename"
|
||||
exit 1
|
||||
# Not here, look at system default
|
||||
if [ ! -e /etc/smegit.ini ] ; then
|
||||
echo "No ini file found $inifiename or /etc/smegit.ini"
|
||||
echo "git-cvs2git.sh <modulename> <organization> [<local>]"
|
||||
exit 1
|
||||
else
|
||||
initfilename="/etc/smegit.ini"
|
||||
fi
|
||||
fi
|
||||
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
@ -59,7 +63,14 @@ fi
|
||||
checkSSL="-k"
|
||||
|
||||
LOCALUser=${local_USER}
|
||||
WORKDIR=$(echo ~)/${smegit_WORKDIR}
|
||||
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}
|
||||
|
@ -4,11 +4,15 @@
|
||||
# monitor results and log
|
||||
#
|
||||
inifilename=$(echo ~)"/.smegit/config"
|
||||
if [ -z $inifilename ] ; then
|
||||
# Not here, look a bit further up
|
||||
echo "No ini file found $inifiename"
|
||||
echo "get-repo-and-build.sh <organisation> <reponame> [<local>]"
|
||||
exit 1
|
||||
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 "get-repo-and-build.sh <organisation> <reponame> [<local>]"
|
||||
exit 1
|
||||
else
|
||||
initfilename="/etc/smegit.ini"
|
||||
fi
|
||||
fi
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
if [[ $line =~ ^\[.*\]$ ]]
|
||||
@ -47,7 +51,14 @@ if [ $3 ] ; then
|
||||
fi
|
||||
ORG_NAME="$1"
|
||||
REPO_NAME="$2"
|
||||
WORKDIR=$(echo ~)${smegit_WORKDIR}
|
||||
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
|
||||
GITFiles=$WORKDIR/GITFiles/$ORG_NAME
|
||||
REPOURL="$GITEAHOST/$ORG_NAME/$REPO_NAME.git"
|
||||
|
||||
|
@ -5,11 +5,15 @@
|
||||
# migrate-repo.sh <reponame> <organisation> [<traget organisation>]
|
||||
#
|
||||
inifilename=$(echo ~)"/.smegit/config"
|
||||
if [ -z $inifilename ] ; then
|
||||
# Not here, look a bit further up
|
||||
echo "No ini file found $inifilename"
|
||||
echo "git-mirror-org.sh <source organisation> <target organisation> [<target organisation>]"
|
||||
exit 1
|
||||
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-mirror-org.sh <source organisation> [<target organisation>]"
|
||||
exit 1
|
||||
else
|
||||
initfilename="/etc/smegit.ini"
|
||||
fi
|
||||
fi
|
||||
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
|
@ -5,11 +5,15 @@
|
||||
# migrate-repo.sh <reponame> <organisation> [<target organisation>]
|
||||
#
|
||||
inifilename=$(echo ~)"/.smegit/config"
|
||||
if [ -z $inifilename ] ; then
|
||||
# Not here
|
||||
echo "No ini file found $inifilename"
|
||||
echo "git_mirror-repo.sh <reponame> <organisation> [<target organisation>]"
|
||||
exit 1
|
||||
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_mirror-repo.sh <reponame> <organisation> [<target organisation>]"
|
||||
exit 1
|
||||
else
|
||||
initfilename="/etc/smegit.ini"
|
||||
fi
|
||||
fi
|
||||
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
@ -29,7 +33,7 @@ done < $inifilename
|
||||
|
||||
if [[ -z $1 ]] ; then
|
||||
echo "git_migrate-repo.sh <reponame> <organisation> [<target organization>]"
|
||||
echo "will migrate repo to ${local_USER} unless <target organisation> specified"
|
||||
echo "will migrate repo to local user unless <target organisation> specified"
|
||||
exit 0
|
||||
fi
|
||||
DEBUG=
|
||||
@ -39,30 +43,29 @@ if [ $DEBUG ] ; then echo "found ini file: $inifilename" ; fi
|
||||
curlsilent="-s"
|
||||
if [ $DEBUG ] ; then curlsilent= ; fi
|
||||
|
||||
REMOTEUser=${remote_USER}
|
||||
REMOTEACCESSTOKEN=${remote_GITEAACCESSTOKEN}
|
||||
LOCALACCESSTOKEN=${local_GITEAACCESSTOKEN}
|
||||
REMOTEGITEAHOST=${remote_GITEAHOST}
|
||||
CLONEADDRESS=$REMOTEGITEAHOST/$2/$1.git
|
||||
LOCALGITEAHOST=${local_GITEAHOST}
|
||||
NEWORG=${local_USER}
|
||||
if [ $3 ] ; then NEWORG=$3 ; fi
|
||||
TARGETORG=${local_USER}
|
||||
if [ $3 ] ; then TARGETORG=$3 ; fi
|
||||
|
||||
# check that the NEWORG exists
|
||||
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$NEWORG)
|
||||
# check that the TARGETORG exists
|
||||
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$TARGETORG)
|
||||
if [[ "$RESPONSE" != "200" ]] ; then
|
||||
echo "$NEWORG does not exist on $LOCALGITEAHOST"
|
||||
echo "$TARGETORG does not exist on $LOCALGITEAHOST"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# And check if this repo already exists on the target
|
||||
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$NEWORG/$1)
|
||||
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$TARGETORG/$1)
|
||||
if [ "$RESPONSE" == "200" ] ; then
|
||||
echo "Repository $NEWORG/$1 already exists on $LOCALGITEAHOST - cannot migrate"
|
||||
echo "Repository $TARGETORG/$1 already exists on $LOCALGITEAHOST - cannot migrate"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $DEBUG ] ; then echo "Mirroring $2/$1 as $NEWORG/$1 on $LOCALGITEAHOST" ; fi
|
||||
if [ $DEBUG ] ; then echo "Mirroring $2/$1 as $TARGETORG/$1 on $LOCALGITEAHOST" ; fi
|
||||
RESPONSE=$(curl $curlsilent -k -X 'POST' \
|
||||
"$LOCALGITEAHOST/api/v1/repos/migrate" \
|
||||
-H 'accept: application/json' \
|
||||
@ -80,7 +83,7 @@ RESPONSE=$(curl $curlsilent -k -X 'POST' \
|
||||
"pull_requests": true,
|
||||
"releases": true,
|
||||
"repo_name": "'"$1"'",
|
||||
"repo_owner": "'"$NEWORG"'",
|
||||
"repo_owner": "'"$TARGETORG"'",
|
||||
"service": "git",
|
||||
"uid": 0,
|
||||
"wiki": true
|
||||
@ -89,10 +92,10 @@ RESPONSE=$(curl $curlsilent -k -X 'POST' \
|
||||
if [ $DEBUG ] ; then echo $? $RESPONSE ; fi
|
||||
|
||||
# And check if this repo is there
|
||||
if [ $DEBUG ] ; then echo "checking that $NEWORG/$1 exists" ; fi
|
||||
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$NEWORG/$1)
|
||||
if [ $DEBUG ] ; then echo "checking that $TARGETORG/$1 exists" ; fi
|
||||
RESPONSE=$(curl $curlsilent -o /dev/null -w "%{http_code}" $LOCALGITEAHOST/$TARGETORG/$1)
|
||||
if [ "$RESPONSE" == "200" ] ; then
|
||||
echo "Repository $NEWORG/$1 has been created and mirrors $2/$1"
|
||||
echo "Repository $TARGETORG/$1 has been created and mirrors $2/$1"
|
||||
else
|
||||
echo "migrate-repo was unable to migrate $2/$1 sucessfully"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user