Run presubmit checks without GerritAccessor if GERRIT_HOST is not set.
When a repository doesn't work with Gerrit, it doesn't make sense to
create GerritAccessor and pass it to presubmit checks.
gerrit.host is stored into git config when codereview.settings file contains GERRIT_HOST item.
Change-Id: I9740950caf85a1da9a6e4ae12e3612625cf0cec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3687235
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Aleksey Khoroshilov <akhoroshilov@brave.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
diff --git a/git_cl.py b/git_cl.py
index c22c682..35767c1 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -805,6 +805,12 @@
return False
return None
+ def GetIsGerrit(self):
+ """Return True if gerrit.host is set."""
+ if self.is_gerrit is None:
+ self.is_gerrit = bool(self._GetConfig('gerrit.host', False))
+ return self.is_gerrit
+
def GetGerritSkipEnsureAuthenticated(self):
"""Return True if EnsureAuthenticated should not be done for Gerrit
uploads."""
@@ -1323,9 +1329,10 @@
remote, remote_branch = self.GetRemoteBranch()
target_ref = GetTargetRef(remote, remote_branch, None)
- args.extend(['--gerrit_url', self.GetCodereviewServer()])
- args.extend(['--gerrit_project', self.GetGerritProject()])
- args.extend(['--gerrit_branch', target_ref])
+ if settings.GetIsGerrit():
+ args.extend(['--gerrit_url', self.GetCodereviewServer()])
+ args.extend(['--gerrit_project', self.GetGerritProject()])
+ args.extend(['--gerrit_branch', target_ref])
author = self.GetAuthor()
issue = self.GetIssue()