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:
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 proper gitlab.const.AccessLevel instances.

Returns:

The expected protected branches

Return type:

list

update_if_required(name, expected, current)

Update a protected branch if required.

Parameters:
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