37 lines
933 B
Python
37 lines
933 B
Python
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])
|
|
)
|