Skip to content

First

FirstVersionStrategy

Bases: VersionStrategyBase

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

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

    def get_versions(self, repository: Repo) -> List[Version]:
        commits = list(repository.iter_commits("--all"))
        commit = commits[0]
        return [
            Version(
                commit_id=commit.hexsha,
                commit_num=0,
                commit_date=commit.committed_datetime,
                files=None,
            )
        ]