initial commit

This commit is contained in:
2025-01-12 19:54:41 -06:00
commit f637529a8d
52 changed files with 2190 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
from .worktree import (
add_worktree,
remove_worktree,
)
from .commit import add_commit
from .branch import (
new_branch,
)

View File

@@ -0,0 +1,9 @@
from utils.branch_details import branch_details
from utils.format import format_branch
from utils.git_commands import git_checkout_branch
def new_branch():
branch_type, branch_id = branch_details()
branch_name = format_branch(branch_type, branch_id)
git_checkout_branch(branch_name)

View File

@@ -0,0 +1,19 @@
from utils.format import format_commit
from utils.git_commands import git_commit
from utils.messages import (
title,
instructions,
commit_instructions,
)
def add_commit(message=''):
commit_title = f"{format_commit()}: "
commit_message = message
if commit_message == '':
title("Commit Message")
instructions(commit_instructions)
commit_message = input(commit_title)
git_commit(f"{commit_title}{commit_message}")

View File

@@ -0,0 +1,60 @@
import os
import subprocess
from .branch import branch_details
from utils.format import format_branch
from utils.git_commands import (
git_add_worktree,
git_remove_worktree,
)
from utils.messages import (
title,
instructions,
worktree_instructions,
)
def add_worktree(worktree=None, auto_install=False):
# Check for bare repo
try:
with open('config') as git_config:
content = ' '.join(git_config.readlines())
if 'bare = true' in content:
# Ask for worktree folder name
if worktree is None:
title('Create Worktree')
instructions(worktree_instructions)
worktree = input('Worktree Directory Name: ')
# Get branch details
branch_type, branch_id = branch_details()
# Format branch name
branch_name = format_branch(
branch_type,
branch_id,
worktree,
)
# Create worktree
git_add_worktree(worktree, branch_name)
# Install NPM packages after worktree creation
if auto_install:
os.chdir(f"./{worktree}")
subprocess.run(['/bin/bash', '-i', '-c', 'nvm use'])
subprocess.run(['npm', 'i'])
exit(0)
except Exception:
print('No worktree found')
exit(1)
def remove_worktree(worktree):
worktree_name = worktree if worktree else input('Worktree to remove: ')
git_remove_worktree(worktree_name)