Skip to main content

Git Service

Git service for repository operations

Overview​

Provides git repository management functionality including initialization, branch management, staging, commits, and repository information.

Classes​

GitService​

Abstract interface for git operations

Inherits from: ABC

Abstract class

Methods​

add_files​
add_files(self, project_path: pathlib.Path, file_patterns: Optional[List[str]] = None) -> bool

Add files to the staging area. If file_patterns is None, adds all files

Parameters:

  • project_path (Path, required)
  • file_patterns (Optional, optional)

Returns: bool

checkout_branch​
checkout_branch(self, branch_name: str, project_path: pathlib.Path) -> bool

Switch to the specified branch

Parameters:

  • branch_name (str, required)
  • project_path (Path, required)

Returns: bool

commit_changes​
commit_changes(self, message: str, project_path: pathlib.Path) -> bool

Commit staged changes with the given message

Parameters:

  • message (str, required)
  • project_path (Path, required)

Returns: bool

configure_platform_line_endings​
configure_platform_line_endings(self, project_path: pathlib.Path) -> bool

Configure git for platform-specific line endings

Parameters:

  • project_path (Path, required)

Returns: bool

create_branch​
create_branch(self, branch_name: str, project_path: pathlib.Path) -> bool

Create a new branch with the given name

Parameters:

  • branch_name (str, required)
  • project_path (Path, required)

Returns: bool

get_current_branch​
get_current_branch(self, project_path: pathlib.Path) -> Optional[str]

Get the name of the current branch

Parameters:

  • project_path (Path, required)

Returns: Optional

get_remote_url​
get_remote_url(self, project_path: pathlib.Path) -> Optional[str]

Get the remote origin URL

Parameters:

  • project_path (Path, required)

Returns: Optional

init_repository​
init_repository(self, project_path: pathlib.Path) -> bool

Initialize a git repository in the specified path

Parameters:

  • project_path (Path, required)

Returns: bool

is_git_repository​
is_git_repository(self, project_path: pathlib.Path) -> bool

Check if the specified path is inside a git repository

Parameters:

  • project_path (Path, required)

Returns: bool