Exemplo n.º 1
0
def test_returns_arguments_for_labels_with_it():
    message = "(md:1864 xy:123:125 something:\"false\" -) A message with an argument"
    labels = get_labels(message)

    assert labels['md'] == '1864'
    assert labels['xy'] == '123:125'
    assert labels['something'] == 'false'
Exemplo n.º 2
0
def test_returns_empty_list_for_non_labeled():
    messages = [
        u"A message without labels",
        u"( A malformed message",
        u"(another malformed:\"message)",
    ]
    for message in messages:
        labels = get_labels(message)
        assert sorted(labels) == []
Exemplo n.º 3
0
def parse_labels(git_log):
    """
    Annotates git log entries with their gitlabels.

    Args:
        git_log: A git log tokenized by tokenize_git_log.

    Returns:
        The same git log with each entry annotated with:
        - labels: A dictionary of labels.
        - pretty_labels: A list of label representations.
        - message: The unlabeled commit message.
    """
    for entry in git_log:
        labels = get_labels(entry['message'])
        entry['labels'] = labels
        entry['pretty_labels'] = sorted(
            "%s:%s" % (k, v) if v else k for k, v in labels.items())
        entry['message'] = remove_labels(entry['message'])

    return git_log
Exemplo n.º 4
0
def test_gets_labels_with_special_characters():
    message = u"(one two - _ *)"
    labels = get_labels(message)
    assert sorted(labels) == ['*', '-', '_', 'one', 'two']
Exemplo n.º 5
0
def test_gets_alphanumeric_labels():
    message = u"(one two three3) A test message"
    labels = get_labels(message)
    assert sorted(labels) == ['one', 'three3', 'two']