Sample Usage¶
Import semantic_branch Python Library¶
[29]:
import semantic_branch.api as semantic_branch
Validating Semantic Branch Names¶
[30]:
# Check if a branch name is valid
semantic_branch.is_valid_semantic_name("feature")
[30]:
True
[31]:
semantic_branch.is_valid_semantic_name("Feature")
[31]:
False
Detecting Branch Types¶
[32]:
# Check if a branch is a feature branch
semantic_branch.is_certain_semantic_branch("feature/add-login", stubs=["feat", "feature"])
[32]:
True
[33]:
semantic_branch.is_certain_semantic_branch("main", stubs=["feat", "feature"])
[33]:
False
Using Semantic Branch Enums¶
[34]:
feature_branch = semantic_branch.SemanticBranchEnum.feature.value
feature_branch
[34]:
SemanticBranch(name='feature', stubs=['feat', 'feature'])
[35]:
feature_branch.name
[35]:
'feature'
[36]:
feature_branch.stubs
[36]:
['feat', 'feature']
[37]:
feature_branch.is_match("feat-123")
[37]:
True
[38]:
feature_branch.is_match("main")
[38]:
False
[39]:
# Access semantic stubs
semantic_branch.SemanticStubEnum.feature.value
[39]:
'feature'
[40]:
semantic_branch.SemanticStubEnum.fix.value
[40]:
'fix'
[ ]: