towhee.utils.git_utils.GitUtils¶
- class towhee.utils.git_utils.GitUtils(author: str, repo: str, root: str = 'https://towhee.io')[source]¶
Bases:
object
A wrapper class to wrap git manipulations.
- Parameters:
author (str) – The author of the repo.
repo (str) – The name of the repo.
root (str) – The root url of the repo.
Methods
A wrapper function for git add.
Clone the repo to specified location.
A wrapper function for git commit.
Check if a repo exists.
A wrapper function for git pull.
A wrapper function for git push.
Check if the local repo is out-dated.
Attributes
author
repo
root
- add(files: Optional[Union[List[str], str]] = None)[source]¶
A wrapper function for git add.
Stage current changes in the repo, please make sure your current woring directory is in the repo.
- Parameters:
files (Union[str, List[str]]) – The relative paths of the files to stage regard to the repo.
- clone(tag: str = 'main', install_reqs: bool = True, local_repo_path: Optional[Union[str, Path]] = None) None [source]¶
Clone the repo to specified location.
- Parameters:
tag (str) – The tag name.
install_reqs (bool) – Whether to install packages from requirements.txt.
self.local_repo_path (Union[str, Path]) – The path to the local repo.
- Raises:
(ValueError) – Raise error if the repo does not exist.
- commit(cmt_msg: str)[source]¶
A wrapper function for git commit.
Commit current changes in the repo.
- Parameters:
cmt_msg (str) – The commit message.
- exists() bool [source]¶
Check if a repo exists.
- Returns:
- (bool)
return True if the repository exists, else False.
- Raises:
(HTTPError) – Raise the error in request.
- pull(remote: str = 'origin', branch: str = 'main')[source]¶
A wrapper function for git pull.
pull from remote, please make sure your current woring directory is in the repo.
- Parameters:
self._repo_path (Union[str, Path]) – The local repo cloned from remote.
remote (str) – The remote repo.
branch (str) – The remote branch.
- push(remote: str = 'origin', branch: str = 'main')[source]¶
A wrapper function for git push.
Push local commits to remote, please make sure your current woring directory is in the repo.
- Parameters:
self._repo_path (Union[str, Path]) – The local repo cloned from remote.
remote (str) – The remote repo.
branch (str) – The remote branch.