##// END OF EJS Templates
auth: don't break hashing in case of user with empty password....
auth: don't break hashing in case of user with empty password. In some cases such as LDAP user created via external scripts users might set the passwords to empty. The hashing uses the md5(password_hash) to store reference to detect password changes and forbid using the same password. In case of pure LDAP users this is not valid, and we shouldn't raise Errors in such case. This change makes it work for empty passwords now.

File last commit:

r552:9a0f45b0 default
r2203:8a18c3c3 default
Show More
extensions.rst
58 lines | 2.0 KiB | text/x-rst | RstLexer

Developing Plugins/Extensions

An Extension or a Plugin is simply a |PY| module with a run method that expects a number of parameters, depending on which event it is listening for. To get an extension working, use the following steps:

  1. Create an extension or plugin using the below example.
  2. Save the plugin inside the :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions` folder.
  3. Add a hook to the :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions/__init__.py` file. For more information, see :ref:`event-listener`.
  4. Restart your |RCM| instance.

Extension example

In the following example, the run method listens for a push to a |repo| and parses the commit.

def run(*args, **kwargs):

    revs = kwargs.get('pushed_revs')
    if not revs:
        return 0

    from rhodecode.lib.utils2 import extract_mentioned_users
    from rhodecode.model.db import Repository

    repo = Repository.get_by_repo_name(kwargs['repository'])
    changesets = []
    reviewers = []

    # reviewer fields from extra_fields, users can store their custom
    # reviewers inside the extra fields to pre-define a set of people who
    # will get notifications about changesets
    field_key = kwargs.get('reviewers_extra_field')
    if field_key:
        for xfield in repo.extra_fields:
            if xfield.field_key == field_key:
                reviewers.extend(xfield.field_value.split())

    vcs_repo = repo.scm_instance_no_cache()
    for rev in kwargs['pushed_revs']:
        cs = vcs_repo.get_changeset(rev) # or get_commit. See API doc
        cs_data = cs.__json__()
        cs_data['mentions'] = extract_mentioned_users(cs_data['message'])
        cs_data['reviewers'] = reviewers
        # optionally add more logic to parse the commits, like reading extra
        # fields of repository to read managers of reviewers
        changesets.append(cs_data)

    return changesets