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

Adding simple add_mirror.sh

* It doesn't function as intended yet.
* Depends on create_gitlab_project.py.
* Updated the readme for some prereqs.
* The python script currently only lists an existing
project.  Returns http clone URL.
parent 9d097bb8
No related branches found
No related tags found
No related merge requests found
......@@ -2,3 +2,10 @@ This adds git mirror functionality to gitlab. The whole purpose of this project
* [Git Mirror](http://stackoverflow.com/questions/2756747/mirror-a-git-repository-by-pulling)
* [Git Push all Branches](http://stackoverflow.com/questions/1914579/set-up-git-to-pull-and-push-all-branches)
# Prereqs
yum install python-setuptools
git clone https://github.com/Itxaka/python-gitlab.git
cd python-gitlab
python setup.py
#!/bin/bash
#Include all user options
. "$(dirname $0)/config.sh"
cd $(dirname $0)
export token_secret gitlab_url gitlab_namespace
python lib/create_gitlab_project.py test2
......@@ -2,3 +2,7 @@
repo_dir="/home/gitmirror/repositories"
mirror_list=("gitlabhq")
token_secret="$(head -n1 /home/gitmirror/private_token)"
#This group will contain all code mirrors
gitlab_namespace="Mirrors"
gitlab_url="https://comet.irt.drexel.edu"
#!/bin/bash
#Include all user options
. /home/gitmirror/gitlab-mirrors/config.sh
. "$(dirname $0)/config.sh"
echo "repo $repo_dir"
echo "GitLab Group $gitlab_group"
#!/usr/bin/env python
from sys import argv,exit
import os
import gitlab
try:
project_name=argv[1]
token_secret=os.environ['token_secret']
gitlab_url=os.environ['gitlab_url']
gitlab_namespace=os.environ['gitlab_namespace']
except KeyError:
print "Environment config missing. Do not run this script standalone."
exit(1)
except IndexError:
print "No project name specified. Do not run this script standalone."
exit(1)
git=gitlab.Gitlab(gitlab_url,token_secret)
#Locate the group
found_group=False
for group in git.getGroups():
if group['name'] == gitlab_namespace:
found_group=group
break
else:
if not found_group:
print "Project namespace (user or group) not found or user does not have permission of existing group."
exit(1)
#Locate existing repository, if it doesn't exist then create it in gitlab
found_project=False
for project in git.getProjects():
if project['namespace']['name'] == gitlab_namespace and project['name'] == project_name:
found_project=project
break
if not found_project:
print "not found"
pass
print found_project['http_url_to_repo']
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