branches module¶
The branches module of GitLab Guard.
- class confirm.gitlab_guard.branches.ProtectedBranches(project, expected, fix)¶
The class which does all the heavy load to compare the expected, with the current protected branches.
- Parameters:
project (gitlab.v4.objects.projects.Project) – The project
expected (dict) – The expected protected branches
fix (bool) – Fix violations automatically
- create(name, expected)¶
Create a new protected branch.
- Parameters:
name (str) – The branch name
expected (dict) – The expected settings
- property current¶
The currently protected branches.
- Returns:
The currently protected branches
- Return type:
dict
- delete(branch)¶
Delete a protected branch.
- Parameters:
branch (gitlab.v4.objects.branches.ProjectProtectedBranch) – The protected branch
- property expected¶
The expected protected branches.
The method will replace the special branch name
__default__with the project’s default branch name. It will also replace the levels with propergitlab.const.AccessLevelinstances.- Returns:
The expected protected branches
- Return type:
list
- update_if_required(name, expected, current)¶
Update a protected branch if required.
- Parameters:
name (str) – The branch name
expected (dict) – The expected settings
current (gitlab.v4.objects.branches.ProjectProtectedBranch) – The current branch
- Returns:
State if something has changed
- Return type:
bool
- verify()¶
Verify the protected branches.
The method will check the project repository status. If it’s disabled the verification will be skipped.
- Returns:
Violations
- Return type:
int
- Raises:
UpdateError – When project couldn’t be updated