diff --git a/add_mirror.sh b/add_mirror.sh index ed58fdaade69ade1ca39bfbba3d477d2ff9e9b99..579135f393544b6a7a713ec92f6f4975f7b9da18 100755 --- a/add_mirror.sh +++ b/add_mirror.sh @@ -1,8 +1,35 @@ #!/bin/bash +#Tue Sep 10 23:01:08 EDT 2013 +#USAGE +# ./add_mirror.sh project_name http://example.com/project.git + #Include all user options . "$(dirname $0)/config.sh" cd $(dirname $0) export token_secret gitlab_url gitlab_namespace gitlab_user -python lib/create_gitlab_project.py test3 + +#Get the remote gitlab url for the specified project. +#If the project doesn't already exist in gitlab then create it. +if python lib/create_gitlab_project.py $1 &> /dev/null;then + gitlab_remote=$(python lib/create_gitlab_project.py $1) +else + echo "There was an unknown issue with create_gitlab_project.py" 1>&2 + exit 1 +fi + +mkdir -p "${repo_dir}/${gitlab_namespace}" + +#create a mirror +cd "${repo_dir}/${gitlab_namespace}" +git clone --mirror $2 "$1" +cd "$1" +#add the gitlab remote +git remote add gitlab ${gitlab_remote} +git config --add remote.gitlab.push '+refs/heads/*:refs/heads/*' +git config --add remote.gitlab.push '+refs/heads/*:refs/heads/*' +#Check the initial repository into gitlab +git fetch +git remote prune origin +git push gitlab diff --git a/git-mirrors.sh b/git-mirrors.sh index 622d113cc741f0a248d93eb7cbf9bdbe44ba286d..7bfaf269b43e43444b1be14524e60db9a4bcc994 100755 --- a/git-mirrors.sh +++ b/git-mirrors.sh @@ -1,4 +1,5 @@ #!/bin/bash +#Tue Sep 10 23:01:08 EDT 2013 #Include all user options diff --git a/lib/create_gitlab_project.py b/lib/create_gitlab_project.py index d600c1e9fd51ec3f2c1e99e7bd6b56a2a97f894c..6ffd2e89c828fc24942b961ce9ba3e4d9ce48e29 100755 --- a/lib/create_gitlab_project.py +++ b/lib/create_gitlab_project.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +#Tue Sep 10 23:01:08 EDT 2013 from sys import argv,exit,stderr import os @@ -57,4 +58,4 @@ if not found_project: print >> stderr, "There was a problem creating {group}/{project}. Did you give {user} user Admin rights in gitlab?".format(group=gitlab_namespace,project=project_name,user=gitlab_user) exit(1) -print found_project['http_url_to_repo'] +print found_project['ssh_url_to_repo'] diff --git a/update_mirror.sh b/update_mirror.sh new file mode 100755 index 0000000000000000000000000000000000000000..d07819b578a725c7aff3e5274bdf19ae84d50762 --- /dev/null +++ b/update_mirror.sh @@ -0,0 +1,22 @@ +#!/bin/bash +#Tue Sep 10 23:01:08 EDT 2013 +#USAGE +# ./update_mirror.sh project_name + + +#Include all user options +. "$(dirname $0)/config.sh" +cd $(dirname $0) + +if [ -z "$1" ];then + echo "Must specify a project_name!" 1>&2 + exit 1 +elif [ ! -d "${repo_dir}/${gitlab_namespace}/$1" ];then + echo "No git repository for $1! Perhaps run add_mirror.sh?" 1>&2 + exit 1 +fi + +cd "${repo_dir}/${gitlab_namespace}/$1" +git fetch +git remote prune origin +git push gitlab