Completed
Push — init ( 57bb17 )
by Michael
06:45
created

GitRepository.repo()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
1
import re
2
3
import giturlparse
0 ignored issues
show
Configuration introduced by
The import giturlparse could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
4
from plumbum.cmd import git
0 ignored issues
show
Configuration introduced by
The import plumbum.cmd could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
5
from invoke import run
0 ignored issues
show
Configuration introduced by
The import invoke could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
6
7
8
class PullRequest:
9
    title = None
10
    description = None
11
    author = None
12
13
    def __init__(self, pr_number, committish):
14
        self.pr_number = pr_number
15
        self.committish = committish
16
    #     - keyed
17
    #     by
18
    #     version
19
    #     - status: open, merged
20
    #     - issue  # => URL
21
    #     - title, description
22
    #     - author
23
    #     - tags
24
    #     - (approvers)
25
    #
26
    #
27
    # - since(version)
28
        pass
29
30
31
def merged_pull_requests():
32
    commit_history = git(
33
        'log --oneline --no-merges --no-color'.split(' ')
34
    ).split('\n')
35
36
    pull_requests = []
37
38
    for index, commit_msg in enumerate(commit_history):
39
        matches = re.compile(
40
            r'^([0-9a-f]{5,40}) Merge pull request #(\w+)',
41
        ).findall(commit_msg)
42
        if matches:
43
            committish, pr_number = matches[0]
44
            pull_requests.append(PullRequest(pr_number, committish))
45
46
    return pull_requests
47
48
49
class GitRepository:
50
    def __init__(self, url=None):
51
        self.parsed_repo = url or giturlparse.parse(
52
            git('config --get remote.origin.url'.split(' '))
53
        )
54
        self.commit_history = git(
55
        'log --oneline --no-merges --no-color'.split(' ')
56
    ).split('\n')
57
58
        self.pull_requests = merged_pull_requests()
59
60
        self.tags = git('tag --list'.split(' '))
61
62
    @property
63
    def repo(self):
64
        return self.parsed_repo.repo
65
66
    @property
67
    def owner(self):
68
        return self.parsed_repo.owner
69
70
    @property
71
    def github(self):
72
        return self.parsed_repo.github
73
74
    @property
75
    def bitbucket(self):
76
        return self.parsed_repo.bitbucket
77
78
    def __str__(self):
79
        return ''.format(
80
81
        )
82