Skip to content
Snippets Groups Projects
Commit c53d4ced authored by Sam Gleske's avatar Sam Gleske
Browse files

Fully working add_mirror.sh

add_mirror.sh script will now add a git mirror to gitlab!

update_mirror.sh will now update mirrors that have been
added to gitlab!
parent 06fc9640
No related branches found
No related tags found
No related merge requests found
#!/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
#!/bin/bash
#Tue Sep 10 23:01:08 EDT 2013
#Include all user options
......
#!/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']
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment