From af157eaf50a50bb987e621cdd9eeb2b26d8ef086 Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Wed, 5 Jul 2023 16:07:06 +0200
Subject: [PATCH] modify proofs repo branch to allow dev pushing

---
 .../management/commands/advance_git_repos.py       | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/scipost_django/production/management/commands/advance_git_repos.py b/scipost_django/production/management/commands/advance_git_repos.py
index 00c16f2d1..9c10e08cc 100644
--- a/scipost_django/production/management/commands/advance_git_repos.py
+++ b/scipost_django/production/management/commands/advance_git_repos.py
@@ -13,6 +13,7 @@ from common.utils import get_current_domain
 from gitlab import Gitlab
 from gitlab.v4.objects import Group, Project
 from gitlab.exceptions import GitlabGetError
+from gitlab.const import AccessLevel
 
 import arxiv
 import requests
@@ -197,6 +198,19 @@ class Command(BaseCommand):
             }
         )
 
+        # Allow Developers to push to the protected "main" branch
+        # Protected branches lay on top of the branches. Deleting and recreating them is
+        # the only way to change their settings and does not affect the branches themselves
+        project.protectedbranches.delete("main")
+        project.protectedbranches.create(
+            {
+                "name": "main",
+                "merge_access_level": AccessLevel.MAINTAINER,
+                "push_access_level": AccessLevel.DEVELOPER,
+                "allow_force_push": False,
+            }
+        )
+
         self.stdout.write(
             self.style.SUCCESS(f"Copied pure templates to {repo.git_path}")
         )
-- 
GitLab