Stage all changes, commit, and push to the remote.
(self,
commit_message: str,
local_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION,
remote_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION,
force: bool = False)
| 117 | f'\n{file_name_suffix} filter=lfs diff=lfs merge=lfs -text\n') |
| 118 | |
| 119 | def push(self, |
| 120 | commit_message: str, |
| 121 | local_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION, |
| 122 | remote_branch: Optional[str] = DEFAULT_REPOSITORY_REVISION, |
| 123 | force: bool = False): |
| 124 | """Stage all changes, commit, and push to the remote.""" |
| 125 | warnings.warn( |
| 126 | 'This function is deprecated and will be removed in future ' |
| 127 | 'versions. Please use git command directly or use ' |
| 128 | 'HubApi().upload_folder instead', |
| 129 | DeprecationWarning, |
| 130 | stacklevel=2) |
| 131 | if not isinstance(commit_message, str) or not commit_message: |
| 132 | raise InvalidParameter('commit_message must be provided!') |
| 133 | if not isinstance(force, bool): |
| 134 | raise InvalidParameter('force must be bool') |
| 135 | if not self.git_token: |
| 136 | raise NotLoginException('Must login to push, please login first.') |
| 137 | |
| 138 | self.git_wrapper.config_git_token(self.model_dir, self.git_token) |
| 139 | self.git_wrapper.add_user_info(self.model_base_dir, |
| 140 | self.model_repo_name) |
| 141 | url = self.git_wrapper.get_repo_remote_url(self.model_dir) |
| 142 | |
| 143 | self.git_wrapper.add(self.model_dir, all_files=True) |
| 144 | self.git_wrapper.commit(self.model_dir, commit_message) |
| 145 | self.git_wrapper.push( |
| 146 | repo_dir=self.model_dir, |
| 147 | git_token=self.git_token, |
| 148 | url=url, |
| 149 | local_branch=local_branch, |
| 150 | remote_branch=remote_branch, |
| 151 | force=force) |
| 152 | |
| 153 | def tag(self, |
| 154 | tag_name: str, |