code: def check_clean_master(self, commit=False):
      
      if commit:
        if self.restrict_push_branches:
          branch = self.scm.branch_name
          if branch not in self.restrict_push_branches:
            raise self.InvalidBranchError('Can only push from {}, currently on branch: {}'
                                          .format(' '.join(sorted(self.restrict_push_branches)),
                                                  branch))
  
        if self.restrict_push_urls:
          url = self.scm.server_url
          if url not in self.restrict_push_urls:
            raise self.InvalidRemoteError('Can only push to {}, currently the remote url is: {}'
                                          .format(' '.join(sorted(self.restrict_push_urls)), url))
  
        changed_files = self.scm.changed_files()
        if changed_files:
          raise self.DirtyWorkspaceError('Can only push from a clean branch, found : {}'
                                         .format(' '.join(changed_files)))
      elif self.scm:
        self.log.info('Skipping check for a clean {} branch in test mode.'
                      .format(self.scm.branch_name))
docs: Perform a sanity check on SCM publishing constraints.
  
      Checks for uncommitted tracked files and ensures we're on an allowed branch configured to push
      to an allowed server if `commit` is `True`.
  
      :param bool commit: `True` if a commit is in progress.
      :raise TaskError: on failure