Coverage for /home/delusionalinsanity/bbrepos/matyan/src/matyan/patterns.py: 100%

# Coverage for /home/delusionalinsanity/bbrepos/matyan/src/matyan/patterns.py : 100%

## 16 statements 16 run 0 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | from .config import CONFIG __author__ = 'Artur Barseghyan' __copyright__ = '2019 Artur Barseghyan' __license__ = 'GPL-2.0-only OR LGPL-2.0-or-later' __all__ = ( 'REGEX_PATTERN_BRANCH_NAME', 'REGEX_PATTERN_BRANCH_TYPE', 'REGEX_PATTERN_COMMIT', 'REGEX_PATTERN_COMMIT_LINE', 'REGEX_PATTERN_MERGED_BRANCH_NAME', 'REGEX_PATTERN_TAG', ) def get_branch_types_for_regex() -> str: """Get branch types for regular expression. :return: """ branches_regex_list = [] for branch_key in dict(CONFIG['BranchTypes']).keys(): branches_regex_list.append( r'({FIRST_LETTER}|{first_letter}){the_rest}'.format( FIRST_LETTER=branch_key[0].upper(), first_letter=branch_key[0].lower(), the_rest=branch_key[1:] ) ) return r'|'.join(branches_regex_list) REGEX_PATTERN_BRANCH_TYPE = r'(((?P<branch_type>{branch_types}))\/)?'.format( branch_types=get_branch_types_for_regex() ) REGEX_PATTERN_BRANCH_NAME = REGEX_PATTERN_BRANCH_TYPE + \ r'((?P<ticket_number>[a-zA-Z]{1,7}-\d{4,6})-)?' \ r'(?P<branch_title>[a-zA-Z-\d]*)' REGEX_PATTERN_MERGED_BRANCH_NAME = r'(\s*)' \ r'(' \ r'(Merged in )|' \ r'(Merge pull request .* from )' \ r')' + \ REGEX_PATTERN_BRANCH_NAME REGEX_PATTERN_COMMIT = r'(?P<ticket_number>[a-zA-Z]{1,7}-\d{4,6})?' REGEX_PATTERN_COMMIT_LINE = r'(\s*)' + \ REGEX_PATTERN_COMMIT + \ r'\s?(?P<commit_message>.*)' REGEX_PATTERN_TAG = r'(?P<tag>((\d{1,9}\.)+(\d)+))'