Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Henrik Skov Midtiby
gitlab-assignment-handler
Commits
7d53eb15
Commit
7d53eb15
authored
Dec 20, 2019
by
Henrik Dyrberg Egemose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unprotect master branch.
parent
67fca12b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
8 deletions
+28
-8
gitlab_class_helper/gitlab_class_helper.py
gitlab_class_helper/gitlab_class_helper.py
+15
-1
misc/example_use_case.txt
misc/example_use_case.txt
+13
-7
No files found.
gitlab_class_helper/gitlab_class_helper.py
View file @
7d53eb15
...
...
@@ -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
...
...
misc/example_use_case.txt
View file @
7d53eb15
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment