コード例 #1
0
 def pre(self, node):
     self.repo_level = repo_owner(self.repo)
     # `privilege_level` has only three allowable states: None, SCM_ALLOW_DIRECT_PUSH, and
     # and self.repo_level
     self.privilege_level = None
     self.head = None
     self.justification = None
     try:
         # The hit on LDAP should only happen once at the beginning of the check process.
         # `pre` is the only opportunity to do so before the iteration through the
         # commits in the changegroup by the `check` method.
         self.user_name, self.user_groups = get_user_and_group_affiliations(
         )
     except Exception as e:
         # The `_get_user_and_group_affiliations` method has raised an unexpected exception.
         # It is not likely an LDAP connection error because the `get_scm_groups` method
         # suppresses all LDAP exceptions in favor of logging to stderr and returning None.
         # However,`get_scm_groups` does have other opportunities to raise exceptions that
         # have not been suppressed. As we have no user information at this point, we cannot
         # let the push proceed.
         # Since this method `pre` cannot react to fatal errors, the `None` value in
         # `privilege_level` will abort this check in the future call to method `check`
         print_banner(
             self.ui, b"error",
             LDAP_USER_EXCEPTION_FAILURE_MESSAGE % pycompat.bytestr(e))
         return
     if not self.user_groups:
         # Since this method `pre` cannot react to fatal errors, the `None` value in
         # `privilege_level` will abort this check in the future call to method `check`
         print_banner(self.ui, b"error", LDAP_USER_FAILURE_MESSAGE)
         return
     elif ((self.direct_push_enabled
            or pycompat.bytestr(self.user_name) in self.landing_users)
           and SCM_ALLOW_DIRECT_PUSH in self.user_groups):
         self.privilege_level = SCM_ALLOW_DIRECT_PUSH
     elif self.repo_level in self.user_groups:
         self.privilege_level = self.repo_level
     else:
         # neither SCM_ALLOW_DIRECT_PUSH nor self.repo_level
         # Since this method `pre` cannot react to fatal errors, the `None` value in
         # `privilege_level` will abort this check in the future call to method `check`
         # Note: We should never get here, as the user will not have permission to start
         # a transaction on this repository, but provide a good error message anyway.
         print_banner(self.ui, b"error",
                      INSUFFICIENT_PRIVILEGE_FAILURE_MESSAGE)
コード例 #2
0
def moz_owner_command(repo, proto):
    """Obtain the group owner of the repository."""
    return repo_owner(repo)
コード例 #3
0
def repoinfowebcommand(web):
    group_owner = repo_owner(web.repo)
    return web.sendtemplate(b'repoinfo',
                            archives=web.archivelist(b'tip'),
                            groupowner=group_owner)