original_docstring: Validate if current directory is in a git repo.
  
      Return 0 on success, 1 on error if not in a git repo,
      2 for warning about not being in a git repo
docstring: Validate if current directory is in a git repo.
  Return 0 on success, 1 on error if not in a git repo,
  2 for warning about not being in a git repo
docstring_tokens: Validate if current directory is in a git repo . Return 0 on success 1 on error if not in a git repo 2 for warning about not being in a git repo
code: def validate_git_repo(strict=True):
      """Validate if current directory is in a git repo.
  
      Return 0 on success, 1 on error if not in a git repo,
      2 for warning about not being in a git repo"""
  
      LOGGER.debug('Checking if in a git repository?')
      # python3.3 offers subpocess.DEVNULL for output redirection
      if ((0 == subprocess.call(['git', 'rev-parse'])) and
          (1 == subprocess.call(
                  'git clean -xnd `pwd` | grep "Would remove \./" > /dev/null',
                  shell=True))):
      # we are in a git repository, but not in an ignored directory inside a git
      # repo (i.e. in OF/addons/someAddon)
          LOGGER.debug('Yes, this is in a git repository.')
          # check for uncommitted modifications
          # apparently --quiet is not 100% reliable. Use --exit-code instead
          if 0 != subprocess.call('git diff --exit-code HEAD > /dev/null',
                                   shell=True):
              LOGGER.error('Repository has uncommitted changes, ' +
                           'commit those before continuing!')
              return 1
          else:
              # Check for untracked files
              if not subprocess.call(
                          'git ls-files --others --exclude-standard ' +
                          '--error-unmatch . > /dev/null 2>&1',
                          shell=True):
                  LOGGER.error('Repository has untracked files, ' +
                               'either commit, ignore or delete them.')
                  return 1
              else:
                  LOGGER.debug('Repository clean')
                  return 0
      else:
          if strict is True:
              LOGGER.error('Not in a git repository: ' + os.getcwd())
              return 1
          else:
              LOGGER.warning('Not in a git repository: ' + os.getcwd())
              return 2
code_tokens: def validate_git_repo ( strict = True ) : LOGGER . debug ( 'Checking if in a git repository?' ) if ( ( 0 == subprocess . call ( [ 'git' , 'rev-parse' ] ) ) and ( 1 == subprocess . call ( 'git clean -xnd `pwd` | grep "Would remove \./" > /dev/null' , shell = True ) ) ) : LOGGER . debug ( 'Yes, this is in a git repository.' ) if 0 != subprocess . call ( 'git diff --exit-code HEAD > /dev/null' , shell = True ) : LOGGER . error ( 'Repository has uncommitted changes, ' + 'commit those before continuing!' ) return 1 else : if not subprocess . call ( 'git ls-files --others --exclude-standard ' + '--error-unmatch . > /dev/null 2>&1' , shell = True ) : LOGGER . error ( 'Repository has untracked files, ' + 'either commit, ignore or delete them.' ) return 1 else : LOGGER . debug ( 'Repository clean' ) return 0 else : if strict is True : LOGGER . error ( 'Not in a git repository: ' + os . getcwd ( ) ) return 1 else : LOGGER . warning ( 'Not in a git repository: ' + os . getcwd ( ) ) return 2
short_docstring: Validate if current directory is in a git repo.
short_docstring_tokens: Validate if current directory is in a git repo .
comment: """Validate if current directory is in a git repo.
  
      Return 0 on success, 1 on error if not in a git repo,
      2 for warning about not being in a git repo"""$SEP$# python3.3 offers subpocess.DEVNULL for output redirection$SEP$# we are in a git repository, but not in an ignored directory inside a git$SEP$# repo (i.e. in OF/addons/someAddon)$SEP$# check for uncommitted modifications$SEP$# apparently --quiet is not 100% reliable. Use --exit-code instead$SEP$# Check for untracked files