def update_remote_branch(self, validate=False): ''' Pulls from remote repository. ''' if self.is_repo_link: return self.linked_subproject.update_remote_branch(validate) # Update weblate.logger.info('updating repo %s', self.__unicode__()) try: try: self.git_repo.git.remote('update', 'origin') except git.GitCommandError: # There might be another attempt on pull in same time # so we will sleep a bit an retry sleep_while_git_locked() self.git_repo.git.remote('update', 'origin') except Exception as error: error_text = str(error) weblate.logger.error('Failed to update Git repo: %s', error_text) if validate: if 'Host key verification failed' in error_text: raise ValidationError(_( 'Failed to verify SSH host key, please add ' 'them in SSH page in the admin interface.' )) raise ValidationError( _('Failed to fetch git repository: %s') % error_text )
def update_remote_branch(self, validate=False): ''' Pulls from remote repository. ''' if self.is_repo_link: return self.linked_subproject.update_remote_branch(validate) # Update weblate.logger.info('updating repo %s', self.__unicode__()) try: try: self.git_repo.git.remote('update', 'origin') except git.GitCommandError: # There might be another attempt on pull in same time # so we will sleep a bit an retry sleep_while_git_locked() self.git_repo.git.remote('update', 'origin') except Exception as error: error_text = str(error) weblate.logger.error('Failed to update Git repo: %s', error_text) if validate: if 'Host key verification failed' in error_text: raise ValidationError( _('Failed to verify SSH host key, please add ' 'them in SSH page in the admin interface.')) raise ValidationError( _('Failed to fetch git repository: %s') % error_text)
def git_commit(self, request, author, timestamp, force_commit=False, sync=False, skip_push=False): ''' Wrapper for commiting translation to git. force_commit forces commit with lazy commits enabled sync updates git hash stored within the translation (otherwise translation rescan will be needed) ''' gitrepo = self.git_repo # Is there something for commit? if not self.git_needs_commit(): return False # Can we delay commit? if not force_commit and appsettings.LAZY_COMMITS: weblate.logger.info( 'Delaying commiting %s in %s as %s', self.filename, self, author ) return False # Do actual commit with git lock weblate.logger.info( 'Commiting %s in %s as %s', self.filename, self, author ) with self.subproject.git_lock: try: self.__git_commit(gitrepo, author, timestamp, sync) except git.GitCommandError: # There might be another attempt on commit in same time # so we will sleep a bit an retry sleep_while_git_locked() self.__git_commit(gitrepo, author, timestamp, sync) # Push if we should if (self.subproject.project.push_on_commit and not skip_push and self.can_push()): self.subproject.do_push(request, force_commit=False) return True
def git_commit(self, request, author, timestamp, force_commit=False, sync=False, skip_push=False): ''' Wrapper for commiting translation to git. force_commit forces commit with lazy commits enabled sync updates git hash stored within the translation (otherwise translation rescan will be needed) ''' gitrepo = self.git_repo # Is there something for commit? if not self.git_needs_commit(): return False # Can we delay commit? if not force_commit and appsettings.LAZY_COMMITS: weblate.logger.info('Delaying commiting %s in %s as %s', self.filename, self, author) return False # Do actual commit with git lock weblate.logger.info('Commiting %s in %s as %s', self.filename, self, author) with self.subproject.git_lock: try: self.__git_commit(gitrepo, author, timestamp, sync) except git.GitCommandError: # There might be another attempt on commit in same time # so we will sleep a bit an retry sleep_while_git_locked() self.__git_commit(gitrepo, author, timestamp, sync) # Push if we should if (self.subproject.project.push_on_commit and not skip_push and self.can_push()): self.subproject.do_push(request, force_commit=False) return True