initial commit
This commit is contained in:
36
bash/.git-formatter/utils/format.py
Normal file
36
bash/.git-formatter/utils/format.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import re
|
||||
from .git_commands import git_current_branch
|
||||
from .repo_format import (
|
||||
branch_format,
|
||||
commit_format,
|
||||
)
|
||||
|
||||
|
||||
def format_branch(branch_type, branch_id, worktree_name=''):
|
||||
if branch_type != '' and branch_id != '':
|
||||
return (
|
||||
branch_format
|
||||
.replace('BRANCH_TYPE', branch_type)
|
||||
.replace('BRANCH_ID', branch_id)
|
||||
)
|
||||
|
||||
if branch_type == '' and branch_id == '' and worktree_name != '':
|
||||
return worktree_name
|
||||
|
||||
if branch_type == '' and branch_id != '':
|
||||
return branch_id
|
||||
|
||||
return 'Error: Something went wrong'
|
||||
|
||||
|
||||
def format_commit():
|
||||
branch_list = re.findall(r'([a-zA-Z0-9-]+)', git_current_branch())
|
||||
|
||||
if len(branch_list) == 1:
|
||||
return branch_list[0]
|
||||
elif len(branch_list) > 1:
|
||||
return (
|
||||
commit_format
|
||||
.replace('BRANCH_TYPE', branch_list[0])
|
||||
.replace('BRANCH_ID', branch_list[1])
|
||||
)
|
||||
Reference in New Issue
Block a user