Skip to main content

Git Operations Helper

Git Operations Helper - focused on git repository operations.

Overview

This helper handles: - Repository root discovery - Branch operations and validation - Git status checks - Branch existence validation

Classes

GitOperationsHelper

Helper for git repository operations.

Methods

check_branch_exists
check_branch_exists(self, branch_name: str) -> bool

Check if a git branch exists.

Parameters:

  • branch_name (str, required) - Name of the branch to check

Returns: bool

check_git_repository
check_git_repository(self) -> bool

Check if current directory is in a git repository.

Returns: bool

get_author_name
get_author_name(self) -> str

Get git author name for current repository.

Returns: str

get_current_branch
get_current_branch(self) -> Optional[str]

Get current git branch name.

Returns: Optional

get_repo_root
get_repo_root(self) -> pathlib.Path

Get repository root directory using git command.

Returns: Path

When scripts run from .specify/scripts/, we need to find the project root that contains the .specify directory, not the script execution directory.

is_feature_branch
is_feature_branch(self, branch_name: Optional[str] = None) -> bool

Check if current or specified branch is a feature branch.

Parameters:

  • branch_name (Optional, optional) - Branch name to check. If None, uses current branch.

Returns: bool

is_no_branch_workflow
is_no_branch_workflow(self) -> bool

Check if we're using a no-branch workflow (main/master only).

Returns: bool