Skip to content

Current

CurrentVersionStrategy

Bases: VersionStrategyBase

Strategy to get the current version of a project from a VCS repository (e.g. git)

Source code in src/vcs/current.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class CurrentVersionStrategy(VersionStrategyBase):
    """
    Strategy to get the current version of a project from a VCS repository (e.g. git)
    """

    def get_versions(self, repository: Repo) -> List[Version]:
        commit = repository.commit().hexsha
        commit_num = [
            i
            for i, _ in enumerate(repository.iter_commits("--all"))
            if _.hexsha == commit
        ][0]
        return [
            Version(
                commit_id=commit,
                commit_num=commit_num,
                commit_date=repository.commit().committed_datetime,
                files=None,
            )
        ]