qxmt.utils.git module#
- qxmt.utils.git.get_commit_id(repo_path=None)#
Get the commit ID of the current git repository. if the user is not using git version control, return “[Not using Git version control]”.
- Parameters:
repo_path (Optional[Path | str]) – git repository path. Defaults to None.
- Returns:
git commit ID
- Return type:
str
- qxmt.utils.git.get_git_add_code(diff=None, repo_path=None, logger=<Logger qxmt.utils.git (INFO)>)#
Get the added code from the git diff.
- Parameters:
diff (Optional[str]) – string of git diff
repo_path (Optional[Path | str]) – git repository path. Defaults to None.
logger (Logger) – logger. Defaults to LOGGER.
- Returns:
added code
- Return type:
str
- qxmt.utils.git.get_git_diff(repo_path=None, logger=<Logger qxmt.utils.git (INFO)>)#
Get the git diff of the current git repository. if the current directory is not a git repository, return an empty string.
- Parameters:
repo_path (Optional[Path | str]) – git repository path. Defaults to None.
logger (Logger) – logger. Defaults to LOGGER.
- Returns:
git diff
- Return type:
str
- qxmt.utils.git.get_git_rm_code(diff=None, repo_path=None, logger=<Logger qxmt.utils.git (INFO)>)#
Get the removed code from the git diff.
- Parameters:
diff (Optional[str]) – string of git diff
repo_path (Optional[Path | str]) – git repository path. Defaults to None.
logger (Logger) – logger. Defaults to LOGGER.
- Returns:
removed code
- Return type:
str
- qxmt.utils.git.is_git_available()#
Check if git is available in the system.
- Returns:
whether git is available or not
- Return type:
bool