From 68f21f0475e83f839bd8e25de482d1aa60582edd Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 15 Jul 2020 22:29:32 +0100 Subject: gitlab: Ignore failure to set the default branch In testing the change to define the default branch for single repositories, I found that GitLab will reject a change of default branch if the branch does not yet exist. (It doesn't seem to do this when creating a repository.) Ignore failure to change the default branch, as we will fix it on the next run after the branch has been created. --- lorrycontroller/gitlab.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lorrycontroller/gitlab.py b/lorrycontroller/gitlab.py index 0b5e1c2..266861c 100644 --- a/lorrycontroller/gitlab.py +++ b/lorrycontroller/gitlab.py @@ -76,13 +76,22 @@ class GitlabDownstream(hosts.DownstreamHost): else: logging.info('Project %s exists in local GitLab already.', repo_path) - if 'head' in metadata \ - and project.default_branch != metadata['head']: - project.default_branch = metadata['head'] + if 'description' in metadata \ and project.description != metadata['description']: project.description = metadata['description'] project.save() + + # This will fail if we haven't created the branch yet. + # We'll fix it next time round. + try: + if 'head' in metadata \ + and project.default_branch != metadata['head']: + project.default_branch = metadata['head'] + project.save() + except gitlab.GitlabUpdateError: + pass + return path_comps = repo_path.split('/') -- cgit v1.2.1