Coverage for .nox/test-3-9/lib/python3.9/site-packages/nskit/mixer/repo.py: 85%
27 statements
« prev ^ index » next coverage.py v7.4.2, created at 2024-02-25 17:38 +0000
« prev ^ index » next coverage.py v7.4.2, created at 2024-02-25 17:38 +0000
1"""A base recipe object for a code (git) repo."""
2from typing import Callable, List, Optional
4from pydantic import EmailStr, Field, HttpUrl
6from nskit.common.configuration import BaseConfiguration
7from nskit.mixer import hooks
8from nskit.mixer.components import LicenseOptionsEnum, Recipe
11class GitConfig(BaseConfiguration):
12 """Git Configuration for the Git Repo."""
14 initial_branch_name: str = 'main'
15 git_flow: bool = True
17 @property
18 def default_branch(self):
19 """Get the default branch."""
20 if self.git_flow:
21 return 'develop'
22 else:
23 return self.initial_branch_name
26class RepoMetadata(BaseConfiguration):
27 """Repository/package metadata information."""
29 repo_separator: str = '-'
30 owner: str = Field(..., description="Who is the owner of the repo")
31 email: EmailStr = Field(..., description="The email for the repo owner")
32 description: str = Field('', description="A summary description for the repo")
33 url: HttpUrl = Field(..., description='The Repository url.')
36class CodeRecipe(Recipe):
37 """Recipe for a code repo.
39 Includes default git init and precommit install hooks.
40 """
41 repo: RepoMetadata
42 post_hooks: Optional[List[Callable]] = Field(
43 [hooks.git.GitInit(), hooks.pre_commit.PrecommitInstall()],
44 validate_default=True,
45 description='Hooks that can be used to modify a recipe path and context after writing'
46 )
47 git: GitConfig = GitConfig()
48 language: str = 'python'
49 license: Optional[LicenseOptionsEnum] = None
51 def get_pipeline_filenames(self):
52 """Get CICD Pipeline filenames."""
53 return []