Add upstream parameter when building an owners client.

code-owners plugins wants a git ref in Gerrit (e.g. refs/heads/master)
while Depot Tools wants a local git ref (e.g. refs/remotes/origin/main,
or a git hash).

Add an upstream parameters to be used by Depot Tools, separate from
a Gerrit ref expected by owners_client.

Change-Id: Ieed97a186e3140b3f82830efa189dbe3e4d8c806
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2730049
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
Edward Lesmes
2021-03-02 23:52:54 +00:00
committed by LUCI CQ
parent c3a48f9ded
commit 1eaaab5c1f
4 changed files with 13 additions and 16 deletions

View File

@@ -176,12 +176,9 @@ class DepotToolsClient(OwnersClient):
self._db.override_files = self._GetOriginalOwnersFiles()
def _GetOriginalOwnersFiles(self):
remote, _ = scm.GIT.FetchUpstreamTuple(self._root)
branch = ''.join(scm.GIT.RefToRemoteRef(self._branch, remote))
return {
f: scm.GIT.GetOldContents(self._root, f, branch).splitlines()
for _, f in scm.GIT.CaptureStatus(self._root, branch)
f: scm.GIT.GetOldContents(self._root, f, self._branch).splitlines()
for _, f in scm.GIT.CaptureStatus(self._root, self._branch)
if os.path.basename(f) == 'OWNERS'
}
@@ -232,11 +229,11 @@ class GerritClient(OwnersClient):
return self._owners_cache[path]
def GetCodeOwnersClient(root, host, project, branch):
def GetCodeOwnersClient(root, upstream, host, project, branch):
"""Get a new OwnersClient.
Defaults to GerritClient, and falls back to DepotToolsClient if code-owners
plugin is not available."""
# TODO(crbug.com/1183447): Use code-owners plugin if available on host once
# code-owners plugin issues have been fixed.
return DepotToolsClient(root, branch)
return DepotToolsClient(root, upstream)