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