Code examples

The following section illustrates the core inner logic. The examples show issue processing on the code level.

Let’s create a model situation:

rules.cfg:

[patterns]
John=title:^Python
Judy=label:[Nn]etworking

[fallback]
label=Need assignment

We’ll use 2 issues for demonstration:

  • issue1: title: Python rules, label: networking issue, assignees: Frank

  • issue2: title: python rules, label: Slow Networking, assignees: (none)

Checking for rule match

Check that the rules linked to the specified user match the given issue.

>>> check_match(issue1, patterns['John'])
True
>>> check_match(issue1, patterns['Judy'])
True
>>> check_match(issue2, patterns['John'])
False

Processing single issues

Process a single issue with the append strategy.

>>> process_issue(None, issue1, config, True)
   = Frank
   + John
   + Judy
True

Now do it again with the change strategy. Frank should be replaced.

>>> config['strategy'] = 'change'
>>> process_issue(None, issue1, config, True)
   - Frank
   + John
   + Judy
True

Set strategy: populate an unassigned issue

>>> config['strategy'] = 'set'
>>> process_issue(None, issue2, config, True)
   + Judy
True

Set strategy: application on a populated issue does nothing

>>> process_issue(None, issue1, config, True)
   = Frank
True