impl#
This module implements the Git branch strategy related automation.
- class aws_ops_alpha.git.impl.GitRepo(dir_repo: Optional[Path] = None, sem_branch_rule: Optional[SemanticBranchRule] = None)[source]#
Detect the current git repo, branch, commit information.
The instance of this class is the entry point of all kinds of git related variables, methods.
This is a generic class. This project provides two common git repo setup, the
MultiGitRepoandMonoGitRepo.- Parameters:
dir_repo – the path of the git repo root folder. there should be a .git folder under this folder.
sem_branch_rule – A pre-defined semantic branch rule that only accept certain semantic branch names.
- property git_branch_name: Optional[str]#
Return the human friendly git branch name. Some CI vendor would use
refs/heads/branch_name, we only keep thebranch_namepart.
- property semantic_branch_part: str#
An abstract method to get the part of the full branch name to detect the semantic name.
For example, in mono-repo setup, you may have multiple projects in one git repo and the full branch name would have the project name as the common prefix, in this example, the method should strip the project name and return the rest part of the branch name.
- aws_ops_alpha.git.impl.extract_semantic_branch_name_for_multi_repo(git_branch_name: str) str[source]#
Extract the semantic branch name from the full git branch name.
Examples:
>>> extract_semantic_branch_name_for_multi_repo("main") 'main' >>> extract_semantic_branch_name_for_multi_repo("feature/add-this-feature") 'feature'
- aws_ops_alpha.git.impl.extract_semantic_branch_name_for_mono_repo(git_branch_name: str) str[source]#
Extract the semantic branch name from the full git branch name. Since this is mono repo, the first part of the full git branch usually are the project name, we are looking for the second part.
Examples:
>>> extract_semantic_branch_name_for_multi_repo("main") 'main' >>> extract_semantic_branch_name_for_multi_repo("my_project/feature/add-this-feature") 'feature'
- class aws_ops_alpha.git.impl.MultiGitRepo(dir_repo: Optional[Path] = None, sem_branch_rule: Optional[SemanticBranchRule] = None)[source]#
Each project is held on an entirely separate, version-controlled repository.
- property semantic_branch_part: str#
An abstract method to get the part of the full branch name to detect the semantic name.
For example, in mono-repo setup, you may have multiple projects in one git repo and the full branch name would have the project name as the common prefix, in this example, the method should strip the project name and return the rest part of the branch name.
- class aws_ops_alpha.git.impl.MonoGitRepo(dir_repo: Optional[Path] = None, sem_branch_rule: Optional[SemanticBranchRule] = None)[source]#
A monorepo is a version-controlled code repository that holds many projects. While these projects may be related, they are often logically independent and run by different teams
- property semantic_branch_part: str#
An abstract method to get the part of the full branch name to detect the semantic name.
For example, in mono-repo setup, you may have multiple projects in one git repo and the full branch name would have the project name as the common prefix, in this example, the method should strip the project name and return the rest part of the branch name.