Skip to content

Instantly share code, notes, and snippets.

@lukasheinrich
Created May 11, 2018 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukasheinrich/6a22bd46be6da2cafc3baccf4738e0bc to your computer and use it in GitHub Desktop.
Save lukasheinrich/6a22bd46be6da2cafc3baccf4738e0bc to your computer and use it in GitHub Desktop.
token = "TOKEN"
projname = 'testtemplaterepo9'
import gitlab
import subprocess
from cookiecutter.main import cookiecutter
gl = gitlab.Gitlab("https://gitlab.cern.ch",token,api_version=4)
gl.auth()
project = gl.projects.create({'name': projname})
remoteurl = project.attributes['http_url_to_repo']
remoteurl = remoteurl.replace('https://gitlab.cern.ch','https://:@gitlab.cern.ch:8443')
cookiecutter('https://:@gitlab.cern.ch:8443/atlas-asg/AnalysisRepositoryTemplate.git',
extra_context={'project_name': projname})
subprocess.Popen('cd {}; git init; git remote add origin {}; git add --all; git commit -m "initial commit"; git push origin master'.format(projname,remoteurl), shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment