unprotect master branch.

parent 67fca12b
......@@ -121,7 +121,7 @@ class GitlabClassHelper:
def push_git_repo_to_repositories(self, local_path: str, repositories: List[str], group_id: int = None):
"""
Push local repository to list of remote repositories
Push local repository to list of remote empty repositories
"""
use_group_id, _ = self.check_group_id(group_id)
for repo in repositories:
......@@ -148,6 +148,20 @@ class GitlabClassHelper:
else:
raise requests.HTTPError('%s for url: %s' % (resp.json()['message'], url))
def unprotect_master_branch(self, repositories: List[str], group_id: int = None):
"""
Unprotect master branch
"""
use_group_id, _ = self.check_group_id(group_id)
for repo in repositories:
repo_id = self.get_repo_id(repo, use_group_id)
branch_url = self.path + '/projects/%d/protected_branches/master' % repo_id
branch_resp = requests.delete(branch_url, headers=self.headers)
if branch_resp.ok:
print('Unprotected master branch in project %s' % repo)
else:
raise requests.HTTPError('%s for url: %s' % (branch_resp.json()['message'], branch_url))
def enter_class(self, group_name: str, id_of_parent_group: int) -> int:
"""
Entering group_name as a subgroup of that parent as the new working group
......
......@@ -29,13 +29,6 @@ Id of the group: 123.
Working in group: 123 - "test-rmurv2".
Created project "hw1-adam" in "test-rmurv2".
Created project "hw1-birger" in "test-rmurv2".
>>> class_helper.add_students_to_repositories(
repositories = list_of_repo_names['repository'],
user_ids = list_of_repo_names['userid'],
group_id = 123)
Working in group: 123 - "test-rmurv2".
Added "adam_id" to the project "hw1-adam".
Added "birger_id" to the project "hw1-birger".
>>> class_helper.push_git_repo_to_repositories(
local_path = "hw1",
repositories = list_of_repo_names['repository'],
......@@ -43,6 +36,19 @@ Added "birger_id" to the project "hw1-birger".
Working in group: 123 - "test-rmurv2".
Pushed git repo "hw1" to "hw1-adam".
Pushed git repo "hw1" to "hw1-birger".
>>> class_helper.unprotect_master_branch(
repositories = list_of_repo_names['repository']
group_id = 123)
Working in group: 123 - "test-rmurv2".
Unprotected master branch in project hw1-adam
Unprotected master branch in project hw1-birger
>>> class_helper.add_students_to_repositories(
repositories = list_of_repo_names['repository'],
user_ids = list_of_repo_names['userid'],
group_id = 123)
Working in group: 123 - "test-rmurv2".
Added "adam_id" to the project "hw1-adam".
Added "birger_id" to the project "hw1-birger".
>>> exit()
# Fetch student answers to the first assignment
......
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