Stage all changes, commit, and push to the remote.
(self,
commit_message: str,
branch: Optional[str] = DEFAULT_DATASET_REVISION,
force: bool = False)
| 230 | return self.repo_work_dir if cloned else '' |
| 231 | |
| 232 | def push(self, |
| 233 | commit_message: str, |
| 234 | branch: Optional[str] = DEFAULT_DATASET_REVISION, |
| 235 | force: bool = False): |
| 236 | """Stage all changes, commit, and push to the remote.""" |
| 237 | warnings.warn( |
| 238 | 'This function is deprecated and will be removed in future ' |
| 239 | 'versions. Please use git command directly or use ' |
| 240 | 'HubApi().upload_folder instead', |
| 241 | DeprecationWarning, |
| 242 | stacklevel=2) |
| 243 | if not isinstance(commit_message, str) or not commit_message: |
| 244 | raise InvalidParameter('commit_message must be provided!') |
| 245 | if not isinstance(force, bool): |
| 246 | raise InvalidParameter('force must be bool') |
| 247 | if not self.git_token: |
| 248 | raise NotLoginException('Must login to push, please login first.') |
| 249 | |
| 250 | self.git_wrapper.config_git_token(self.repo_work_dir, self.git_token) |
| 251 | self.git_wrapper.add_user_info(self.repo_base_dir, self.repo_name) |
| 252 | try: |
| 253 | remote_url = self.git_wrapper.get_repo_remote_url( |
| 254 | self.repo_work_dir) |
| 255 | remote_url = self.git_wrapper.remove_token_from_url(remote_url) |
| 256 | except GitError: |
| 257 | remote_url = self.repo_url |
| 258 | |
| 259 | self.git_wrapper.pull(self.repo_work_dir) |
| 260 | self.git_wrapper.add(self.repo_work_dir, all_files=True) |
| 261 | self.git_wrapper.commit(self.repo_work_dir, commit_message) |
| 262 | self.git_wrapper.push( |
| 263 | repo_dir=self.repo_work_dir, |
| 264 | git_token=self.git_token, |
| 265 | url=remote_url, |
| 266 | local_branch=branch, |
| 267 | remote_branch=branch, |
| 268 | force=force) |
no test coverage detected