Commit 3bf2e6a9 authored by alexandre's avatar alexandre

Fixed some variables and made the script a module

parent 06859a7b
......@@ -6,6 +6,9 @@ import json
from bottle import request, route, run
REPO_PATH = "/home/git/repositories.new"
@route('/', method='POST')
def index():
print("received request")
......@@ -14,10 +17,10 @@ def index():
data = json.load(request.body)
repo = data.get("repository")
git_http_url = repo.get("git_ssh_url")
git_http_url = repo.get("git_http_url")
repo_name = git_http_url.split("/")[-1]
repo_local_path = os.path.join("/tmp", repo_name)
repo_local_path = os.path.join(REPO_PATH, repo_name)
if os.path.isdir(repo_local_path):
# print("repo exists. Pulling")
......@@ -26,7 +29,8 @@ def index():
else:
# print("repo don't exist. Cloning")
cmd = "git clone --bare %s" % git_http_url
subprocess.Popen(shlex.split(cmd), cwd="/tmp")
subprocess.Popen(shlex.split(cmd), cwd=REPO_PATH)
run(host='localhost', port=8080)
if __name__ == "__main__":
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