Commit 6612f256 authored by ESW course's avatar ESW course

Update gitlab webhook to work with current version of sync script

parent ef6c5859
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2018 Michal Sojka <michal.sojka@cvut.cz>
# Copyright (c) 2018, 2021 Michal Sojka <michal.sojka@cvut.cz>
# Copyright (c) 2017 Pascal Stauffer
#
# License: GPLv3
......@@ -18,7 +18,6 @@ simple config file is shown below:
https://gitlab.fel.cvut.cz/B161_B4M36ESW/materials:
gitlab_token: PTP2NSS2XMttNVpJfmk6
dir: /home/me/repo-dir
brutegit: git@brutegit.felk.cvut.cz:2018l_b4m36esw/ae.git
To use HTTPS, you can generate a self-signed certificate with this
command:
......@@ -78,7 +77,6 @@ class RequestHandler(BaseHTTPRequestHandler):
# get directory and token from config file
gitlab_token = config[project]['gitlab_token']
gitdir = config[project]['dir']
brutegit = config[project]['brutegit']
except KeyError as err:
self.send_response(500, "KeyError")
logging.error("Project '%s' not found in %s (%s)", project, args.cfg, err)
......@@ -89,20 +87,18 @@ class RequestHandler(BaseHTTPRequestHandler):
if gitlab_token_header == gitlab_token:
try:
if not os.path.isdir(gitdir):
# Clone and setup repository for mirroring
# Initial clone of the repository
logging.info("Clonning " + ssh_url + " to " + gitdir)
subprocess.run(["git", "clone", "--mirror", ssh_url, gitdir],
check=True, stdout=sys.stdout, stderr=sys.stderr)
os.chdir(gitdir)
subprocess.run(["git", "remote", "add", "brutegit", brutegit],
check=True, stdout=sys.stdout, stderr=sys.stderr)
subprocess.run(["git", "fetch", "brutegit", "master:ae"],
check=True, stdout=sys.stdout, stderr=sys.stderr)
else:
logging.info("Fetching updates from " + ssh_url)
os.chdir(gitdir)
subprocess.run(["git", "fetch", ssh_url],
check=True, stdout=sys.stdout, stderr=sys.stderr)
subprocess.run(["git", "reset", "--soft", "FETCH_HEAD"],
check=True, stdout=sys.stdout, stderr=sys.stderr)
logging.info("Syncing to brutegit")
subprocess.run([brutegit_ae_sync],
......
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