summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lwirzenius@wikimedia.org>2019-07-01 18:51:35 +0300
committerLars Wirzenius <lwirzenius@wikimedia.org>2019-07-01 18:51:35 +0300
commitabbfdd7d704c3ab9e1ab55efcc61a422be3fdb0d (patch)
treea3d4692647fff453e94791fa3c728912b505b305
parentf92ff0b8a23ffa899f74f0e02609eac7ddbe8d06 (diff)
downloadwmf-ci-arch-abbfdd7d704c3ab9e1ab55efcc61a422be3fdb0d.tar.gz
Fix: vcsworker.py to run git push in the cloned directory
-rwxr-xr-xvcsworker.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/vcsworker.py b/vcsworker.py
index d42b1f1..2cac2cd 100755
--- a/vcsworker.py
+++ b/vcsworker.py
@@ -15,11 +15,11 @@ GITLAB_DOMAIN = 'wmf-gitlab3.vm.liw.fi'
GITLAB_PROJECT = 'liw'
-def runcmd(argv, timeout):
+def runcmd(cwd, argv, timeout):
logging.info('Running command: %r', argv)
try:
p = subprocess.run(
- argv, timeout=timeout, stdout=subprocess.PIPE,
+ argv, cwd=cwd, timeout=timeout, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except subprocess.TimeoutExpired:
logging.error('Command took too long (timeout %r)', timeout)
@@ -45,25 +45,23 @@ def clone(url, ref, dirname):
shutil.rmtree(dirname)
argv = ['git', 'clone', '-q', '-b', ref, url, dirname]
- return runcmd(argv, MAX_CLONE_TIME)
+ return runcmd('.', argv, MAX_CLONE_TIME)
def remove(token, gitlab_domain, gitlab_project, name):
- snippet = urllib.parse.quote('%s/%s.git' % (gitlab_project, name), safe='')
+ snippet = urllib.parse.quote('%s/%s' % (gitlab_project, name), safe='')
url = 'https://%s/api/v4/projects/%s' % (gitlab_domain, snippet)
argv = ['curl', '-HPRIVATE-TOKEN: %s' % token, '-X', 'DELETE', url]
- return runcmd(argv, MAX_REMOVE_TIME)
+ return runcmd('.', argv, MAX_REMOVE_TIME)
-def push(dirname, gitlab_domain, gitlab_project, name):
+def push(dirname, gitlab_domain, gitlab_project, ref, name):
logging.info('Pushing %s to %s as %s', dirname, gitlab_domain, name)
url = 'ssh://git@%s/%s/%s.git' % (gitlab_domain, gitlab_project, name)
- logging.debug('Pushing to repo URL: %s', url)
-
- argv = ['git', 'push', url, 'master']
- return runcmd(argv, MAX_PUSH_TIME)
+ argv = ['git', 'push', url, '%s:master' % ref]
+ return runcmd(dirname, argv, MAX_PUSH_TIME)
def main():
@@ -94,7 +92,7 @@ def main():
if clone(url, ref, dirname):
if remove(token, GITLAB_DOMAIN, GITLAB_PROJECT, name):
- if push(dirname, GITLAB_DOMAIN, GITLAB_PROJECT, name):
+ if push(dirname, GITLAB_DOMAIN, GITLAB_PROJECT, ref, name):
logging.info('Repository copied successfully')
return