How to use the gitlint.git.repository_root function in gitlint

To help you get started, we’ve selected a few gitlint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sk- / git-lint / test / unittest / test_git.py View on Github external
def test_repository_root_ok(self):
        with mock.patch('subprocess.check_output',
                        return_value=b'/home/user/repo\n') as git_call:
            self.assertEqual('/home/user/repo', git.repository_root())
            git_call.asser_called_once_with(
                ['git', 'rev-parse', '--show-toplevel'])
github sk- / git-lint / test / unittest / test_git.py View on Github external
def test_repository_root_error(self):
        with mock.patch('subprocess.check_output',
                        side_effect=subprocess.CalledProcessError(1, '', '')):
            self.assertEqual(None, git.repository_root())
github aosp-mirror / platform_development / tools / checkstyle / checkstyle.py View on Github external
def _GetModifiedFiles(commit, out=sys.stdout):
  root = git.repository_root()
  pending_files = git.modified_files(root, True)
  if pending_files:
    out.write(ERROR_UNCOMMITTED)
    sys.exit(1)

  modified_files = git.modified_files(root, True, commit)
  modified_files = {f: modified_files[f] for f
                    in modified_files if f.endswith('.java')}
  return modified_files
github aosp-mirror / platform_development / tools / checkstyle / checkstyle.py View on Github external
def _WarnIfUntrackedFiles(out=sys.stdout):
  """Prints a warning and a list of untracked files if needed."""
  root = git.repository_root()
  untracked_files = git.modified_files(root, False)
  untracked_files = {f for f in untracked_files if f.endswith('.java')}
  if untracked_files:
    out.write(ERROR_UNTRACKED)
    for untracked_file in untracked_files:
      out.write(untracked_file + '\n')
    out.write('\n')