Commit 9bc17884 authored by alexandre's avatar alexandre

Basic primitive version

import os
import shlex
import subprocess
import json
from bottle import request, route, run
@route('/', method='POST')
def index():
print("received request")
if request.headers.get('X-Gitlab-Event') == 'Push Hook':
# print("push hook")
data = json.load(request.body)
repo = data.get("repository")
git_http_url = repo.get("git_ssh_url")
repo_name = git_http_url.split("/")[-1]
repo_local_path = os.path.join("/tmp", repo_name)
if os.path.isdir(repo_local_path):
# print("repo exists. Pulling")
cmd = "git fetch origin master:master"
subprocess.Popen(shlex.split(cmd), cwd=repo_local_path)
# print("repo don't exist. Cloning")
cmd = "git clone --bare %s" % git_http_url
subprocess.Popen(shlex.split(cmd), cwd="/tmp")
run(host='localhost', port=8080)
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