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

1"""A base recipe object for a code (git) repo.""" 

2from typing import Callable, List, Optional 

3 

4from pydantic import EmailStr, Field, HttpUrl 

5 

6from nskit.common.configuration import BaseConfiguration 

7from nskit.mixer import hooks 

8from nskit.mixer.components import LicenseOptionsEnum, Recipe 

9 

10 

11class GitConfig(BaseConfiguration): 

12 """Git Configuration for the Git Repo.""" 

13 

14 initial_branch_name: str = 'main' 

15 git_flow: bool = True 

16 

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 

24 

25 

26class RepoMetadata(BaseConfiguration): 

27 """Repository/package metadata information.""" 

28 

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.') 

34 

35 

36class CodeRecipe(Recipe): 

37 """Recipe for a code repo. 

38 

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 

50 

51 def get_pipeline_filenames(self): 

52 """Get CICD Pipeline filenames.""" 

53 return []