Commit c96b1fe2 authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmgp: rewrite git clone

parent 1f950acb
...@@ -250,11 +250,16 @@ get_all_remote_branches() ...@@ -250,11 +250,16 @@ get_all_remote_branches()
git checkout sisyphus || git checkout master || git checkout $CURRENTBRANCH git checkout sisyphus || git checkout master || git checkout $CURRENTBRANCH
} }
has_ssh_access()
{
ssh $GIRARHOST help >/dev/null 2>&1
}
git_clone() git_clone()
{ {
local RREPO="$1" local RREPO="$1"
# Test if ssh access is available # Test if ssh access is available
if [ -z "$PUBLICACCESS" ] && ssh $GIRARHOST help >/dev/null 2>&1 ; then if [ -z "$PUBLICACCESS" ] && has_ssh_access ; then
echo "Clone from $GIRARHOST:$RREPO ..." echo "Clone from $GIRARHOST:$RREPO ..."
git clone $GIRARHOST:$RREPO git clone $GIRARHOST:$RREPO
else else
...@@ -263,6 +268,11 @@ git_clone() ...@@ -263,6 +268,11 @@ git_clone()
fi fi
} }
exist_git_repo()
{
ssh $GIRARHOST ls $1 >/dev/null 2>&1
}
# clone remote git # clone remote git
if [ -n "$CLONEGIT" ] ; then if [ -n "$CLONEGIT" ] ; then
# http://git.altlinux.org/gears/N/NAME.git # http://git.altlinux.org/gears/N/NAME.git
...@@ -270,26 +280,38 @@ if [ -n "$CLONEGIT" ] ; then ...@@ -270,26 +280,38 @@ if [ -n "$CLONEGIT" ] ; then
RREPO="/gears/$REPOPATH" RREPO="/gears/$REPOPATH"
if [ -z "$MIGRATEGIRAR" ] ; then if [ -z "$MIGRATEGIRAR" ] ; then
if ! git_clone $RREPO; then if ! git_clone $RREPO ; then
# http://git.altlinux.org/srpms/N/NAME.git # http://git.altlinux.org/srpms/N/NAME.git
RREPO="/srpms/$REPOPATH" RREPO="/srpms/$REPOPATH"
git_clone $RREPO || fatal "Can't clone $RREPO." git_clone $RREPO || fatal "Can't clone $RREPO."
fi fi
else else
[ -z "$PUBLICACCESS" ] || fatal "Can't remote clone via public access" [ -z "$PUBLICACCESS" ] || fatal "Can't remote clone via public access"
echo "Remote clone from $RREPO ..." if exist_git_repo $RREPO ; then
if ! ssh $GIRARHOST clone $RREPO packages/$PKGNAME.git ; then
# http://git.altlinux.org/srpms/N/NAME.git
RREPO="/srpms/$REPOPATH"
echo "Remote clone from $RREPO ..." echo "Remote clone from $RREPO ..."
ssh $GIRARHOST clone $RREPO packages/$PKGNAME.git || warning "Can't remote clone." ssh $GIRARHOST clone $RREPO packages/$PKGNAME.git || warning "Can't remote clone."
else
# http://git.altlinux.org/srpms/N/NAME.git
RREPO="/srpms/$REPOPATH"
if exist_git_repo $RREPO ; then
echo "Remote clone from $RREPO ..."
ssh $GIRARHOST clone $RREPO packages/$PKGNAME.git || warning "Can't remote clone."
else
fatal "$PKGNAME does not exists in /gears or /srpms, can't clone"
fi
fi fi
git clone $GIRARHOST:packages/$PKGNAME.git git clone $GIRARHOST:packages/$PKGNAME.git
if cd $PKGNAME ; then
# add remotes
git remote rename origin $GIRARHOST && git remote add origin $GIRARHOST:$RREPO
cd - >/dev/null
fi
fi fi
# get or update all branches
if cd $PKGNAME ; then if cd $PKGNAME ; then
# get or update all branches
get_all_remote_branches get_all_remote_branches
cd - >/dev/null cd - >/dev/null
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment