Commit 4bb7dacb authored by Mun Yong Jang's avatar Mun Yong Jang Committed by Commit Bot

[presubmit] Address dependent local branches

Bug: 781478
Change-Id: Id07fdca70418c5e564eab8322df51a4004acc937
Reviewed-on: https://chromium-review.googlesource.com/754379Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarNodir Turakulov <nodir@chromium.org>
Commit-Queue: Mun Yong Jang <myjang@google.com>
parent 906a0f8b
......@@ -45,19 +45,24 @@ def CheckChangedConfigs(input_api, output_api):
import collections
import auth
import git_common as git
import git_cl
LUCI_CONFIG_HOST_NAME = 'luci-config.appspot.com'
cl = git_cl.Changelist()
remote, remote_branch = cl.FetchUpstreamTuple(cl.GetBranch())
if not remote_branch:
return [output_api.PresubmitError('Upstream branch has not been set')]
remote_host_url = git.get_remote_url(remote=remote)
remote, remote_branch = cl.GetRemoteBranch()
if remote_branch.startswith('refs/remotes/%s/' % remote):
remote_branch = remote_branch.replace(
'refs/remotes/%s/' % remote, 'refs/heads/', 1)
if remote_branch.startswith('refs/remotes/branch-heads/'):
remote_branch = remote_branch.replace(
'refs/remotes/branch-heads/', 'refs/branch-heads/', 1)
remote_host_url = cl.GetRemoteUrl()
if not remote_host_url:
return [output_api.PresubmitError(
'Remote host url for git has not been defined')]
remote_host_url = remote_host_url.rstrip('/')
if remote_host_url.endswith('.git'):
remote_host_url = remote_host_url[:-len('.git')]
......
......@@ -1907,14 +1907,11 @@ class CannedChecksUnittest(PresubmitTestsBase):
json.load(http_resp).MultipleTimes().AndReturn(http_resp)
mock_cl = self.mox.CreateMock(git_cl.Changelist)
mock_cl.GetBranch().AndReturn('test')
mock_cl.FetchUpstreamTuple('test').AndReturn((host, branch))
mock_cl.GetRemoteBranch().AndReturn(('remote', branch))
mock_cl.GetRemoteUrl().AndReturn(host)
self.mox.StubOutWithMock(git_cl, 'Changelist', use_mock_anything=True)
git_cl.Changelist().AndReturn(mock_cl)
self.mox.StubOutWithMock(git, 'get_remote_url')
git.get_remote_url(remote=host).AndReturn(host)
change1 = presubmit.Change(
'foo', 'foo1', self.fake_root_dir, None, 0, 0, None)
input_api = self.MockInputApi(change1, False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment