-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproject.py
59 lines (43 loc) · 1.45 KB
/
project.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
from gitlab.v4.objects import Project
from kira_setup.decorators import idempotent
#: Used to enforce one-task = one-branch,
#: also has a fallback for dependabot updates:
branch_regex = r'^(issue-\d+)|(dependabot.*)|(master)$'
#: Enforces conventional commits,
#: see https://github.com/wemake-services/kira-release
commit_regex = r"""
^(revert: )?
(feat|fix|docs|build|refactor|chore)
(\(.+\))?:
.{1,50}(refs #\d+)?
"""
@idempotent
def star(project: Project) -> None:
"""
Stars the given project.
API: https://docs.gitlab.com/ee/api/projects.html#star-a-project
"""
project.star()
def configure(project: Project) -> None:
"""
Configures basic things for a new project.
API: https://docs.gitlab.com/ee/api/projects.html#edit-project
"""
project.resolve_outdated_diff_discussions = True
project.only_allow_merge_if_pipeline_succeeds = True
project.only_allow_merge_if_all_discussions_are_resolved = True
project.merge_method = 'ff'
project.save()
def push_rules(project: Project) -> None:
"""
Sets all required push rules for the project.
API: https://docs.gitlab.com/ee/api/projects.html#push-rules-starter
"""
rules = project.pushrules.get()
rules.deny_delete_tag = True
rules.member_check = True
rules.prevent_secrets = True
rules.branch_name_regex = branch_regex
rules.commit_message_regex = commit_regex.replace('\n', '')
rules.save()