summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-15 22:29:32 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-07-30 14:07:46 +0100
commit68f21f0475e83f839bd8e25de482d1aa60582edd (patch)
tree107db8ec63c5f61aec192ebd465254f62daf4bbc
parent1263e62a2fafc590017b52f3e8c5ee4a94d56212 (diff)
downloadlorry-controller-68f21f0475e83f839bd8e25de482d1aa60582edd.tar.gz
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.
-rw-r--r--lorrycontroller/gitlab.py15
1 files 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('/')