• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

roskakori / pygount / 5468364552

pending completion
5468364552

Pull #121

github

web-flow
Merge 409bf29e9 into e2f267b89
Pull Request #121: #112 add graph for git tags

397 of 426 branches covered (93.19%)

45 of 45 new or added lines in 3 files covered. (100.0%)

1118 of 1172 relevant lines covered (95.39%)

3.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.76
/pygount/git_graph.py
1
import re
4✔
2
from typing import Optional
4✔
3

4
from pygount.analysis import SourceScanner
4✔
5
from pygount.git_storage import GitStorage, git_remote_url_and_revision_if_any
4✔
6

7

8
def compile_revisions_regex(revisions_regex_str: str) -> re:
4✔
9
    # TODO#112: fix regex input
10
    # input needs to be fixed because it does not return any matches
11
    return re.compile(revisions_regex_str)
4✔
12

13

14
class GitGraph:
4✔
15
    def __init__(self, source_url: str, revisions_regex_str: Optional[str] = None):
4✔
16
        self._revisions_regex = compile_revisions_regex(revisions_regex_str)
4✔
17
        self._source_url = source_url
4✔
18
        self._git_storage = None
4✔
19

20
    def revisions_to_analyze(self, revisions) -> list[str]:
4✔
21
        # TODO#112: fix regex input
22
        # input needs to be fixed because it does not return any matches
23
        return (
4✔
24
            list(filter(self._revisions_regex.match, map(str, revisions)))
25
            if self._revisions_regex is not None
26
            else revisions
27
        )
28

29
    def execute(self):
4✔
30
        try:
4✔
31
            remote_url, revision = git_remote_url_and_revision_if_any(self._source_url)
4✔
32
            if remote_url is not None:
4!
33
                self._git_storage = GitStorage(remote_url, revision)
4✔
34
                self._git_storage.extract()
4✔
35
                self._git_storage.unshallow()
4✔
36
                revisions_to_analyze = self.revisions_to_analyze(self._git_storage.revisions())
4✔
37

38
                for revision in revisions_to_analyze:
4!
39
                    print(revision)
×
40
                    self._git_storage.checkout(revision)
×
41
                    scanner = SourceScanner([self._git_storage.temp_folder])
×
42
                    print(list(scanner.source_paths()))
×
43
        except OSError as error:
×
44
            raise OSError(f"cannot scan for source files: {error}")
×
45

46
        self._git_storage.close()
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc