def CheckLocalGitState(self):
    """Checks the state of the local git repository.

    Returns:
      A boolean value to indicate if the state is sane.
    """
    if self._command in (u'close', u'create', u'lint', u'update'):
      if not self._git_helper.CheckHasProjectUpstream():
        print(u'{0:s} aborted - missing project upstream.'.format(
            self._command.title()))
        print(u'Run: git remote add upstream {0:s}'.format(self._git_repo_url))
        return False

    elif self._command == u'merge':
      if not self._git_helper.CheckHasProjectOrigin():
        print(u'{0:s} aborted - missing project origin.'.format(
            self._command.title()))
        return False

    if self._command not in (
        u'lint', u'test', u'update-version', u'update_version'):
      if self._git_helper.CheckHasUncommittedChanges():
        print(u'{0:s} aborted - detected uncommitted changes.'.format(
            self._command.title()))
        print(u'Run: git commit')
        return False

    self._active_branch = self._git_helper.GetActiveBranch()
    if self._command in (u'create', u'update'):
      if self._active_branch == u'master':
        print(u'{0:s} aborted - active branch is master.'.format(
            self._command.title()))
        return False

    elif self._command == u'close':
      if self._feature_branch == u'master':
        print(u'{0:s} aborted - feature branch cannot be master.'.format(
            self._command.title()))
        return False

      if self._active_branch != u'master':
        self._git_helper.SwitchToMasterBranch()
        self._active_branch = u'master'

    return True
dataset/ETHPy150Open log2timeline/dfvfs/utils/review.py/ReviewHelper.CheckLocalGitState/original