def check_environment(self): """Checks that a sync can be performed. If a sync can't be performed, sets state to FINISHED. If it can be, sets state to CHECK_CONTINUE or CHECK_NEW, depending on whether the sync is a continue sync or a new sync. """ # Make sure branch is clean if not utils.in_clean_state(): print 'Branch %r not in clean state:' % (self.__branch,) print utils.capture_command('git', 'diff', single_line=False) self.state = self.FINISHED else: # TODO(dhermes): This assumes review_info is not None. Fix this. self.__last_commit = self.__rietveld_info.review_info.last_commit # Using getattr since SYNC_HALTED is not an explicit attribute in # RietveldInfo, hence accessing rietveld_info.sync_halted may result # in an AttributeError. self.__sync_halted = getattr(self.__rietveld_info, utils.SYNC_HALTED, False) if self.__continue: self.state = self.CHECK_CONTINUE else: self.state = self.CHECK_NEW self.advance()
def check_environment(self): """Checks that a sync can be performed. If a sync can't be performed, sets state to FINISHED. If it can be, sets state to CHECK_CONTINUE or CHECK_NEW, depending on whether the sync is a continue sync or a new sync. """ # Make sure branch is clean if not utils.in_clean_state(): print 'Branch %r not in clean state:' % (self.__branch, ) print utils.capture_command('git', 'diff', single_line=False) self.state = self.FINISHED else: # TODO(dhermes): This assumes review_info is not None. Fix this. self.__last_commit = self.__rietveld_info.review_info.last_commit # Using getattr since SYNC_HALTED is not an explicit attribute in # RietveldInfo, hence accessing rietveld_info.sync_halted may result # in an AttributeError. self.__sync_halted = getattr(self.__rietveld_info, utils.SYNC_HALTED, False) if self.__continue: self.state = self.CHECK_CONTINUE else: self.state = self.CHECK_NEW self.advance()
def callback(cls, args, argv): """A callback to begin an ExportAction after arguments are parsed. If the branch is not in a clean state, won't create an ExportAction, will just print 'git diff' and proceed. Args: args: An argparse.Namespace object to extract parameters from. argv: The original command line arguments that were parsed to create args. These may be used in a call to upload.py. Returns: An instance of ExportAction. Just by instantiating the instance, the state machine will begin working. """ current_branch = utils.get_current_branch() if not utils.in_clean_state(): print 'Branch %r not in clean state:' % (current_branch, ) print utils.capture_command('git', 'diff', single_line=False) return if args.no_mail and args.send_patch: raise GitRvException('The flags --no_mail and --send_patch are ' 'mutually exclusive.') # This is to determine whether or not --send_mail should be added to # the upload.py call. If --send_patch is set, we don't need to # send mail. Similarly if --no_mail is set, we should not send mail. no_send_mail = args.no_mail or args.send_patch # Rietveld treats an empty string the same as if the value # was never set. if args.message and not args.title: raise GitRvException('A patch description can only be set if it ' 'also has a title.') commit_subject = commit_description = None if args.title: if len(args.title) > 100: raise GitRvException(utils.SUBJECT_TOO_LONG_TEMPLATE % (args.title, )) # If args.message is '', then both the Title and Description # will take the value of the title. commit_subject = args.title commit_description = args.message or '' return cls(current_branch, args, commit_subject=commit_subject, commit_description=commit_description, no_send_mail=no_send_mail, argv=argv)
def callback(cls, args, argv): """A callback to begin an ExportAction after arguments are parsed. If the branch is not in a clean state, won't create an ExportAction, will just print 'git diff' and proceed. Args: args: An argparse.Namespace object to extract parameters from. argv: The original command line arguments that were parsed to create args. These may be used in a call to upload.py. Returns: An instance of ExportAction. Just by instantiating the instance, the state machine will begin working. """ current_branch = utils.get_current_branch() if not utils.in_clean_state(): print 'Branch %r not in clean state:' % (current_branch,) print utils.capture_command('git', 'diff', single_line=False) return if args.no_mail and args.send_patch: raise GitRvException('The flags --no_mail and --send_patch are ' 'mutually exclusive.') # This is to determine whether or not --send_mail should be added to # the upload.py call. If --send_patch is set, we don't need to # send mail. Similarly if --no_mail is set, we should not send mail. no_send_mail = args.no_mail or args.send_patch # Rietveld treats an empty string the same as if the value # was never set. if args.message and not args.title: raise GitRvException('A patch description can only be set if it ' 'also has a title.') commit_subject = commit_description = None if args.title: if len(args.title) > 100: raise GitRvException(utils.SUBJECT_TOO_LONG_TEMPLATE % (args.title,)) # If args.message is '', then both the Title and Description # will take the value of the title. commit_subject = args.title commit_description = args.message or '' return cls(current_branch, args, commit_subject=commit_subject, commit_description=commit_description, no_send_mail=no_send_mail, argv=argv)
def check_environment(self): """Checks that the current review branch is in a clean state. If not, we can't submit, so sets state to FINISHED after notifying the user of the issue. If it can be, sets state to VERIFY_APPROVAL. In either case, advances the state machine. """ # Make sure branch is clean if not utils.in_clean_state(): print 'Branch %r not in clean state:' % (self.__branch, ) print utils.capture_command('git', 'diff', single_line=False) self.state = self.FINISHED else: self.state = self.VERIFY_APPROVAL self.advance()
def check_environment(self): """Checks that the current review branch is in a clean state. If not, we can't submit, so sets state to FINISHED after notifying the user of the issue. If it can be, sets state to VERIFY_APPROVAL. In either case, advances the state machine. """ # Make sure branch is clean if not utils.in_clean_state(): print 'Branch %r not in clean state:' % (self.__branch,) print utils.capture_command('git', 'diff', single_line=False) self.state = self.FINISHED else: self.state = self.VERIFY_APPROVAL self.advance()