OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
7 | 7 |
8 import os | 8 import os |
9 import StringIO | 9 import StringIO |
10 import stat | 10 import stat |
11 import sys | 11 import sys |
12 import unittest | 12 import unittest |
13 import urlparse | 13 import urlparse |
14 | 14 |
15 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 15 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
16 | 16 |
17 from testing_support.auto_stub import TestCase | 17 from testing_support.auto_stub import TestCase |
18 | 18 |
19 import git_cl | 19 import git_cl |
20 import git_common | 20 import git_common |
21 import git_footers | 21 import git_footers |
22 import subprocess2 | 22 import subprocess2 |
23 | 23 |
| 24 def callError(code=1, cmd='', cwd='', stdout='', stderr=''): |
| 25 return subprocess2.CalledProcessError(code, cmd, cwd, stdout, stderr) |
| 26 |
| 27 |
| 28 CERR1 = callError(1) |
| 29 |
| 30 |
24 class ChangelistMock(object): | 31 class ChangelistMock(object): |
25 # A class variable so we can access it when we don't have access to the | 32 # A class variable so we can access it when we don't have access to the |
26 # instance that's being set. | 33 # instance that's being set. |
27 desc = "" | 34 desc = "" |
28 def __init__(self, **kwargs): | 35 def __init__(self, **kwargs): |
29 pass | 36 pass |
30 def GetIssue(self): | 37 def GetIssue(self): |
31 return 1 | 38 return 1 |
32 def GetDescription(self): | 39 def GetDescription(self): |
33 return ChangelistMock.desc | 40 return ChangelistMock.desc |
34 def UpdateDescription(self, desc): | 41 def UpdateDescription(self, desc): |
35 ChangelistMock.desc = desc | 42 ChangelistMock.desc = desc |
36 | 43 |
| 44 |
37 class PresubmitMock(object): | 45 class PresubmitMock(object): |
38 def __init__(self, *args, **kwargs): | 46 def __init__(self, *args, **kwargs): |
39 self.reviewers = [] | 47 self.reviewers = [] |
40 @staticmethod | 48 @staticmethod |
41 def should_continue(): | 49 def should_continue(): |
42 return True | 50 return True |
43 | 51 |
44 | 52 |
45 class RietveldMock(object): | 53 class RietveldMock(object): |
46 def __init__(self, *args, **kwargs): | 54 def __init__(self, *args, **kwargs): |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 234 |
227 | 235 |
228 class TestGitCl(TestCase): | 236 class TestGitCl(TestCase): |
229 def setUp(self): | 237 def setUp(self): |
230 super(TestGitCl, self).setUp() | 238 super(TestGitCl, self).setUp() |
231 self.calls = [] | 239 self.calls = [] |
232 self._calls_done = [] | 240 self._calls_done = [] |
233 self.mock(subprocess2, 'call', self._mocked_call) | 241 self.mock(subprocess2, 'call', self._mocked_call) |
234 self.mock(subprocess2, 'check_call', self._mocked_call) | 242 self.mock(subprocess2, 'check_call', self._mocked_call) |
235 self.mock(subprocess2, 'check_output', self._mocked_call) | 243 self.mock(subprocess2, 'check_output', self._mocked_call) |
236 self.mock(subprocess2, 'communicate', self._mocked_call) | 244 self.mock(subprocess2, 'communicate', |
| 245 lambda *a, **kw: ([self._mocked_call(*a, **kw), ''], 0)) |
237 self.mock(git_cl.gclient_utils, 'CheckCallAndFilter', self._mocked_call) | 246 self.mock(git_cl.gclient_utils, 'CheckCallAndFilter', self._mocked_call) |
238 self.mock(git_common, 'is_dirty_git_tree', lambda x: False) | 247 self.mock(git_common, 'is_dirty_git_tree', lambda x: False) |
239 self.mock(git_common, 'get_or_create_merge_base', | 248 self.mock(git_common, 'get_or_create_merge_base', |
240 lambda *a: ( | 249 lambda *a: ( |
241 self._mocked_call(['get_or_create_merge_base']+list(a)))) | 250 self._mocked_call(['get_or_create_merge_base']+list(a)))) |
242 self.mock(git_cl, 'BranchExists', lambda _: True) | 251 self.mock(git_cl, 'BranchExists', lambda _: True) |
243 self.mock(git_cl, 'FindCodereviewSettingsFile', lambda: '') | 252 self.mock(git_cl, 'FindCodereviewSettingsFile', lambda: '') |
244 self.mock(git_cl, 'ask_for_data', self._mocked_call) | 253 self.mock(git_cl, 'ask_for_data', self._mocked_call) |
245 self.mock(git_cl.presubmit_support, 'DoPresubmitChecks', PresubmitMock) | 254 self.mock(git_cl.presubmit_support, 'DoPresubmitChecks', PresubmitMock) |
246 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) | 255 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) |
(...skipping 15 matching lines...) Expand all Loading... |
262 if not self.has_failed(): | 271 if not self.has_failed(): |
263 self.assertEquals([], self.calls) | 272 self.assertEquals([], self.calls) |
264 finally: | 273 finally: |
265 super(TestGitCl, self).tearDown() | 274 super(TestGitCl, self).tearDown() |
266 | 275 |
267 def _mocked_call(self, *args, **_kwargs): | 276 def _mocked_call(self, *args, **_kwargs): |
268 self.assertTrue( | 277 self.assertTrue( |
269 self.calls, | 278 self.calls, |
270 '@%d Expected: <Missing> Actual: %r' % (len(self._calls_done), args)) | 279 '@%d Expected: <Missing> Actual: %r' % (len(self._calls_done), args)) |
271 top = self.calls.pop(0) | 280 top = self.calls.pop(0) |
272 if len(top) > 2 and top[2]: | |
273 raise top[2] | |
274 expected_args, result = top | 281 expected_args, result = top |
| 282 if isinstance(result, Exception): |
| 283 exc = result |
| 284 result = None |
| 285 else: |
| 286 exc = None |
275 | 287 |
276 # Also logs otherwise it could get caught in a try/finally and be hard to | 288 # Also logs otherwise it could get caught in a try/finally and be hard to |
277 # diagnose. | 289 # diagnose. |
278 if expected_args != args: | 290 if expected_args != args: |
279 N = 5 | 291 N = 5 |
280 prior_calls = '\n '.join( | 292 prior_calls = '\n '.join( |
281 '@%d: %r' % (len(self._calls_done) - N + i, c[0]) | 293 '@%d: %r' % (len(self._calls_done) - N + i, c[0]) |
282 for i, c in enumerate(self._calls_done[-N:])) | 294 for i, c in enumerate(self._calls_done[-N:])) |
283 following_calls = '\n '.join( | 295 following_calls = '\n '.join( |
284 '@%d: %r' % (len(self._calls_done) + i + 1, c[0]) | 296 '@%d: %r' % (len(self._calls_done) + i + 1, c[0]) |
285 for i, c in enumerate(self.calls[:N])) | 297 for i, c in enumerate(self.calls[:N])) |
286 extended_msg = ( | 298 extended_msg = ( |
287 'A few prior calls:\n %s\n\n' | 299 'A few prior calls:\n %s\n\n' |
288 'This (expected):\n @%d: %r\n' | 300 'This (expected):\n @%d: %r\n' |
289 'This (actual):\n @%d: %r\n\n' | 301 'This (actual):\n @%d: %r\n\n' |
290 'A few following expected calls:\n %s' % | 302 'A few following expected calls:\n %s' % |
291 (prior_calls, len(self._calls_done), expected_args, | 303 (prior_calls, len(self._calls_done), expected_args, |
292 len(self._calls_done), args, following_calls)) | 304 len(self._calls_done), args, following_calls)) |
293 git_cl.logging.error(extended_msg) | 305 git_cl.logging.error(extended_msg) |
294 | 306 |
295 self.fail('@%d\n' | 307 self.fail('@%d\n' |
296 ' Expected: %r\n' | 308 ' Expected: %r\n' |
297 ' Actual: %r' % ( | 309 ' Actual: %r' % ( |
298 len(self._calls_done), expected_args, args)) | 310 len(self._calls_done), expected_args, args)) |
299 | 311 |
300 self._calls_done.append(top) | 312 self._calls_done.append(top) |
301 return result | 313 if exc is None: |
| 314 return result |
| 315 raise exc |
302 | 316 |
303 @classmethod | 317 @classmethod |
304 def _is_gerrit_calls(cls, gerrit=False): | 318 def _is_gerrit_calls(cls, gerrit=False): |
305 return [((['git', 'config', 'rietveld.autoupdate'],), ''), | 319 return [((['git', 'config', 'rietveld.autoupdate'],), ''), |
306 ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] | 320 ((['git', 'config', 'gerrit.host'],), 'True' if gerrit else '')] |
307 | 321 |
308 @classmethod | 322 @classmethod |
309 def _upload_calls(cls, similarity, find_copies, private): | 323 def _upload_calls(cls, similarity, find_copies, private): |
310 return (cls._git_base_calls(similarity, find_copies) + | 324 return (cls._git_base_calls(similarity, find_copies) + |
311 cls._git_upload_calls(private)) | 325 cls._git_upload_calls(private)) |
312 | 326 |
313 @classmethod | 327 @classmethod |
314 def _upload_no_rev_calls(cls, similarity, find_copies): | 328 def _upload_no_rev_calls(cls, similarity, find_copies): |
315 return (cls._git_base_calls(similarity, find_copies) + | 329 return (cls._git_base_calls(similarity, find_copies) + |
316 cls._git_upload_no_rev_calls()) | 330 cls._git_upload_no_rev_calls()) |
317 | 331 |
318 @classmethod | 332 @classmethod |
319 def _git_base_calls(cls, similarity, find_copies): | 333 def _git_base_calls(cls, similarity, find_copies): |
320 if similarity is None: | 334 if similarity is None: |
321 similarity = '50' | 335 similarity = '50' |
322 similarity_call = ((['git', 'config', '--int', '--get', | 336 similarity_call = ((['git', 'config', '--int', |
323 'branch.master.git-cl-similarity'],), '') | 337 'branch.master.git-cl-similarity'],), CERR1) |
324 else: | 338 else: |
325 similarity_call = ((['git', 'config', '--int', | 339 similarity_call = ((['git', 'config', '--int', |
326 'branch.master.git-cl-similarity', similarity],), '') | 340 'branch.master.git-cl-similarity', similarity],), '') |
327 | 341 |
328 if find_copies is None: | 342 if find_copies is None: |
329 find_copies = True | 343 find_copies = True |
330 find_copies_call = ((['git', 'config', '--int', '--get', | 344 find_copies_call = ((['git', 'config', '--bool', |
331 'branch.master.git-find-copies'],), '') | 345 'branch.master.git-find-copies'],), CERR1) |
332 else: | 346 else: |
333 val = str(int(find_copies)) | 347 val = str(find_copies).lower() |
334 find_copies_call = ((['git', 'config', '--int', | 348 find_copies_call = ((['git', 'config', '--bool', |
335 'branch.master.git-find-copies', val],), '') | 349 'branch.master.git-find-copies', val],), '') |
336 | 350 |
337 if find_copies: | 351 if find_copies: |
338 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', | 352 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', |
339 '--find-copies-harder', '-l100000', '-C'+similarity, | 353 '--find-copies-harder', '-l100000', '-C'+similarity, |
340 'fake_ancestor_sha', 'HEAD'],), '+dat') | 354 'fake_ancestor_sha', 'HEAD'],), '+dat') |
341 else: | 355 else: |
342 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', | 356 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', |
343 '-M'+similarity, 'fake_ancestor_sha', 'HEAD'],), '+dat') | 357 '-M'+similarity, 'fake_ancestor_sha', 'HEAD'],), '+dat') |
344 | 358 |
345 return [ | 359 return [ |
346 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 360 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
347 similarity_call, | 361 similarity_call, |
348 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 362 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
349 find_copies_call, | 363 find_copies_call, |
350 ] + cls._is_gerrit_calls() + [ | 364 ] + cls._is_gerrit_calls() + [ |
351 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 365 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
352 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 366 ((['git', 'config', '--int', 'branch.master.rietveldissue'],), CERR1), |
353 ((['git', 'config', 'branch.master.gerritissue'],), ''), | 367 ((['git', 'config', '--int', 'branch.master.gerritissue'],), CERR1), |
354 ((['git', 'config', 'rietveld.server'],), | 368 ((['git', 'config', 'rietveld.server'],), |
355 'codereview.example.com'), | 369 'codereview.example.com'), |
356 ((['git', 'config', 'branch.master.merge'],), 'master'), | 370 ((['git', 'config', 'branch.master.merge'],), 'master'), |
357 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 371 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
358 ((['get_or_create_merge_base', 'master', 'master'],), | 372 ((['get_or_create_merge_base', 'master', 'master'],), |
359 'fake_ancestor_sha'), | 373 'fake_ancestor_sha'), |
360 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ | 374 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ |
361 ((['git', 'rev-parse', '--show-cdup'],), ''), | 375 ((['git', 'rev-parse', '--show-cdup'],), ''), |
362 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 376 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
363 ((['git', 'diff', '--name-status', '--no-renames', '-r', | 377 ((['git', 'diff', '--name-status', '--no-renames', '-r', |
364 'fake_ancestor_sha...', '.'],), | 378 'fake_ancestor_sha...', '.'],), |
365 'M\t.gitignore\n'), | 379 'M\t.gitignore\n'), |
366 ((['git', 'config', 'branch.master.rietveldpatchset'],), | 380 ((['git', 'config', '--int', 'branch.master.rietveldpatchset'],), CERR1), |
367 ''), | |
368 ((['git', 'log', '--pretty=format:%s%n%n%b', | 381 ((['git', 'log', '--pretty=format:%s%n%n%b', |
369 'fake_ancestor_sha...'],), | 382 'fake_ancestor_sha...'],), |
370 'foo'), | 383 'foo'), |
371 ((['git', 'config', 'user.email'],), 'me@example.com'), | 384 ((['git', 'config', 'user.email'],), 'me@example.com'), |
372 stat_call, | 385 stat_call, |
373 ((['git', 'log', '--pretty=format:%s\n\n%b', | 386 ((['git', 'log', '--pretty=format:%s\n\n%b', |
374 'fake_ancestor_sha..HEAD'],), | 387 'fake_ancestor_sha..HEAD'],), |
375 'desc\n'), | 388 'desc\n'), |
376 ((['git', 'config', 'rietveld.bug-prefix'],), ''), | 389 ((['git', 'config', 'rietveld.bug-prefix'],), ''), |
377 ] | 390 ] |
(...skipping 18 matching lines...) Expand all Loading... |
396 ((['git', 'config', 'core.editor'],), ''), | 409 ((['git', 'config', 'core.editor'],), ''), |
397 ] + cc_call + private_call + [ | 410 ] + cc_call + private_call + [ |
398 ((['git', 'config', 'branch.master.base-url'],), ''), | 411 ((['git', 'config', 'branch.master.base-url'],), ''), |
399 ((['git', 'config', 'rietveld.pending-ref-prefix'],), ''), | 412 ((['git', 'config', 'rietveld.pending-ref-prefix'],), ''), |
400 ((['git', | 413 ((['git', |
401 'config', '--local', '--get-regexp', '^svn-remote\\.'],), | 414 'config', '--local', '--get-regexp', '^svn-remote\\.'],), |
402 (('', None), 0)), | 415 (('', None), 0)), |
403 ((['git', 'rev-parse', '--show-cdup'],), ''), | 416 ((['git', 'rev-parse', '--show-cdup'],), ''), |
404 ((['git', 'svn', 'info'],), ''), | 417 ((['git', 'svn', 'info'],), ''), |
405 ((['git', 'config', 'rietveld.project'],), ''), | 418 ((['git', 'config', 'rietveld.project'],), ''), |
406 ((['git', | 419 ((['git', 'config', '--int', 'branch.master.rietveldissue', '1'],), ''), |
407 'config', 'branch.master.rietveldissue', '1'],), ''), | |
408 ((['git', 'config', 'branch.master.rietveldserver', | 420 ((['git', 'config', 'branch.master.rietveldserver', |
409 'https://codereview.example.com'],), ''), | 421 'https://codereview.example.com'],), ''), |
410 ((['git', | 422 ((['git', |
411 'config', 'branch.master.rietveldpatchset', '2'],), ''), | 423 'config', '--int', 'branch.master.rietveldpatchset', '2'],), ''), |
412 ] + cls._git_post_upload_calls() | 424 ] + cls._git_post_upload_calls() |
413 | 425 |
414 @classmethod | 426 @classmethod |
415 def _git_post_upload_calls(cls): | 427 def _git_post_upload_calls(cls): |
416 return [ | 428 return [ |
417 ((['git', 'rev-parse', 'HEAD'],), 'hash'), | 429 ((['git', 'rev-parse', 'HEAD'],), 'hash'), |
418 ((['git', 'symbolic-ref', 'HEAD'],), 'hash'), | 430 ((['git', 'symbolic-ref', 'HEAD'],), 'hash'), |
419 ((['git', | 431 ((['git', |
420 'config', 'branch.hash.last-upload-hash', 'hash'],), ''), | 432 'config', 'branch.hash.last-upload-hash', 'hash'],), ''), |
421 ((['git', 'config', 'rietveld.run-post-upload-hook'],), ''), | 433 ((['git', 'config', 'rietveld.run-post-upload-hook'],), ''), |
422 ] | 434 ] |
423 | 435 |
424 @staticmethod | 436 @staticmethod |
425 def _git_sanity_checks(diff_base, working_branch, get_remote_branch=True): | 437 def _git_sanity_checks(diff_base, working_branch, get_remote_branch=True): |
426 fake_ancestor = 'fake_ancestor' | 438 fake_ancestor = 'fake_ancestor' |
427 fake_cl = 'fake_cl_for_patch' | 439 fake_cl = 'fake_cl_for_patch' |
428 return [ | 440 return [ |
429 ((['git', | 441 ((['git', |
430 'rev-parse', '--verify', diff_base],), fake_ancestor), | 442 'rev-parse', '--verify', diff_base],), fake_ancestor), |
431 ((['git', | 443 ((['git', |
432 'merge-base', fake_ancestor, 'HEAD'],), fake_ancestor), | 444 'merge-base', fake_ancestor, 'HEAD'],), fake_ancestor), |
433 ((['git', | 445 ((['git', |
434 'rev-list', '^' + fake_ancestor, 'HEAD'],), fake_cl), | 446 'rev-list', '^' + fake_ancestor, 'HEAD'],), fake_cl), |
435 # Mock a config miss (error code 1) | 447 # Mock a config miss (error code 1) |
436 ((['git', | 448 ((['git', |
437 'config', 'gitcl.remotebranch'],), (('', None), 1)), | 449 'config', 'gitcl.remotebranch'],), CERR1), |
438 ] + ([ | 450 ] + ([ |
439 # Call to GetRemoteBranch() | 451 # Call to GetRemoteBranch() |
440 ((['git', | 452 ((['git', |
441 'config', 'branch.%s.merge' % working_branch],), | 453 'config', 'branch.%s.merge' % working_branch],), |
442 'refs/heads/master'), | 454 'refs/heads/master'), |
443 ((['git', | 455 ((['git', |
444 'config', 'branch.%s.remote' % working_branch],), 'origin'), | 456 'config', 'branch.%s.remote' % working_branch],), 'origin'), |
445 ] if get_remote_branch else []) + [ | 457 ] if get_remote_branch else []) + [ |
446 ((['git', 'rev-list', '^' + fake_ancestor, | 458 ((['git', 'rev-list', '^' + fake_ancestor, |
447 'refs/remotes/origin/master'],), ''), | 459 'refs/remotes/origin/master'],), ''), |
448 ] | 460 ] |
449 | 461 |
450 @classmethod | 462 @classmethod |
451 def _dcommit_calls_1(cls): | 463 def _dcommit_calls_1(cls): |
452 return [ | 464 return [ |
453 ((['git', 'config', 'rietveld.autoupdate'],), | 465 ((['git', 'config', 'rietveld.autoupdate'],), |
454 ''), | 466 ''), |
455 ((['git', 'config', 'rietveld.pending-ref-prefix'],), | 467 ((['git', 'config', 'rietveld.pending-ref-prefix'],), |
456 ''), | 468 ''), |
457 ((['git', | 469 ((['git', |
458 'config', '--local', '--get-regexp', '^svn-remote\\.'],), | 470 'config', '--local', '--get-regexp', '^svn-remote\\.'],), |
459 ((('svn-remote.svn.url svn://svn.chromium.org/chrome\n' | 471 ((('svn-remote.svn.url svn://svn.chromium.org/chrome\n' |
460 'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'), | 472 'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'), |
461 None), | 473 None), |
462 0)), | 474 0)), |
463 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), | 475 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), |
464 ((['git', 'config', '--int', '--get', | 476 ((['git', 'config', '--int', |
465 'branch.working.git-cl-similarity'],), ''), | 477 'branch.working.git-cl-similarity'],), CERR1), |
466 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), | 478 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), |
467 ((['git', 'config', '--int', '--get', | 479 ((['git', 'config', '--bool', |
468 'branch.working.git-find-copies'],), ''), | 480 'branch.working.git-find-copies'],), CERR1), |
469 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), | 481 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), |
470 ((['git', | 482 ((['git', |
471 'config', 'branch.working.rietveldissue'],), '12345'), | 483 'config', '--int', 'branch.working.rietveldissue'],), '12345'), |
472 ((['git', | 484 ((['git', |
473 'config', 'rietveld.server'],), 'codereview.example.com'), | 485 'config', 'rietveld.server'],), 'codereview.example.com'), |
474 ((['git', | 486 ((['git', |
475 'config', 'branch.working.merge'],), 'refs/heads/master'), | 487 'config', 'branch.working.merge'],), 'refs/heads/master'), |
476 ((['git', 'config', 'branch.working.remote'],), 'origin'), | 488 ((['git', 'config', 'branch.working.remote'],), 'origin'), |
477 ((['git', 'config', 'branch.working.merge'],), | 489 ((['git', 'config', 'branch.working.merge'],), |
478 'refs/heads/master'), | 490 'refs/heads/master'), |
479 ((['git', 'config', 'branch.working.remote'],), 'origin'), | 491 ((['git', 'config', 'branch.working.remote'],), 'origin'), |
480 ((['git', 'rev-list', '--merges', | 492 ((['git', 'rev-list', '--merges', |
481 '--grep=^SVN changes up to revision [0-9]*$', | 493 '--grep=^SVN changes up to revision [0-9]*$', |
(...skipping 16 matching lines...) Expand all Loading... |
498 def _dcommit_calls_normal(cls): | 510 def _dcommit_calls_normal(cls): |
499 return [ | 511 return [ |
500 ((['git', 'rev-parse', '--show-cdup'],), ''), | 512 ((['git', 'rev-parse', '--show-cdup'],), ''), |
501 ((['git', 'rev-parse', 'HEAD'],), | 513 ((['git', 'rev-parse', 'HEAD'],), |
502 '00ff397798ea57439712ed7e04ab96e13969ef40'), | 514 '00ff397798ea57439712ed7e04ab96e13969ef40'), |
503 ((['git', | 515 ((['git', |
504 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', | 516 'diff', '--name-status', '--no-renames', '-r', 'fake_ancestor_sha...', |
505 '.'],), | 517 '.'],), |
506 'M\tPRESUBMIT.py'), | 518 'M\tPRESUBMIT.py'), |
507 ((['git', | 519 ((['git', |
508 'config', 'branch.working.rietveldpatchset'],), '31137'), | 520 'config', '--int', 'branch.working.rietveldpatchset'],), '31137'), |
509 ((['git', 'config', 'branch.working.rietveldserver'],), | 521 ((['git', 'config', 'branch.working.rietveldserver'],), |
510 'codereview.example.com'), | 522 'codereview.example.com'), |
511 ((['git', 'config', 'user.email'],), 'author@example.com'), | 523 ((['git', 'config', 'user.email'],), 'author@example.com'), |
512 ((['git', 'config', 'rietveld.tree-status-url'],), ''), | 524 ((['git', 'config', 'rietveld.tree-status-url'],), ''), |
513 ] | 525 ] |
514 | 526 |
515 @classmethod | 527 @classmethod |
516 def _dcommit_calls_bypassed(cls): | 528 def _dcommit_calls_bypassed(cls): |
517 return [ | 529 return [ |
518 ((['git', 'config', 'branch.working.rietveldserver'],), | 530 ((['git', 'config', 'branch.working.rietveldserver'],), |
519 'codereview.example.com'), | 531 'codereview.example.com'), |
520 ] | 532 ] |
521 | 533 |
522 @classmethod | 534 @classmethod |
523 def _dcommit_calls_3(cls): | 535 def _dcommit_calls_3(cls): |
524 return [ | 536 return [ |
525 ((['git', | 537 ((['git', |
526 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 538 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
527 '-l100000', '-C50', 'fake_ancestor_sha', | 539 '-l100000', '-C50', 'fake_ancestor_sha', |
528 'refs/heads/working'],), | 540 'refs/heads/working'],), |
529 (' PRESUBMIT.py | 2 +-\n' | 541 (' PRESUBMIT.py | 2 +-\n' |
530 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), | 542 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), |
531 ((['git', 'show-ref', '--quiet', '--verify', | 543 ((['git', 'show-ref', '--quiet', '--verify', |
532 'refs/heads/git-cl-commit'],), | 544 'refs/heads/git-cl-commit'],), ''), |
533 (('', None), 0)), | |
534 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), | 545 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), |
535 ((['git', 'show-ref', '--quiet', '--verify', | 546 ((['git', 'show-ref', '--quiet', '--verify', |
536 'refs/heads/git-cl-cherry-pick'],), ''), | 547 'refs/heads/git-cl-cherry-pick'],), CERR1), |
537 ((['git', 'rev-parse', '--show-cdup'],), '\n'), | 548 ((['git', 'rev-parse', '--show-cdup'],), '\n'), |
538 ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), | 549 ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), |
539 ((['git', 'reset', '--soft', 'fake_ancestor_sha'],), ''), | 550 ((['git', 'reset', '--soft', 'fake_ancestor_sha'],), ''), |
540 ((['git', 'commit', '-m', | 551 ((['git', 'commit', '-m', |
541 'Issue: 12345\n\nR=john@chromium.org\n\n' | 552 'Issue: 12345\n\nR=john@chromium.org\n\n' |
542 'Review URL: https://codereview.example.com/12345 .'],), | 553 'Review URL: https://codereview.example.com/12345 .'],), |
543 ''), | 554 ''), |
544 ((['git', 'config', 'rietveld.force-https-commit-url'],), ''), | 555 ((['git', 'config', 'rietveld.force-https-commit-url'],), ''), |
545 ((['git', | 556 ((['git', |
546 'svn', 'dcommit', '-C50', '--no-rebase', '--rmdir'],), | 557 'svn', 'dcommit', '-C50', '--no-rebase', '--rmdir'],), |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 self._dcommit_calls_3()) | 742 self._dcommit_calls_3()) |
732 git_cl.main(['dcommit', '--bypass-hooks']) | 743 git_cl.main(['dcommit', '--bypass-hooks']) |
733 | 744 |
734 | 745 |
735 @classmethod | 746 @classmethod |
736 def _gerrit_ensure_auth_calls(cls, issue=None, skip_auth_check=False): | 747 def _gerrit_ensure_auth_calls(cls, issue=None, skip_auth_check=False): |
737 cmd = ['git', 'config', '--bool', 'gerrit.skip-ensure-authenticated'] | 748 cmd = ['git', 'config', '--bool', 'gerrit.skip-ensure-authenticated'] |
738 if skip_auth_check: | 749 if skip_auth_check: |
739 return [((cmd, ), 'true')] | 750 return [((cmd, ), 'true')] |
740 | 751 |
741 calls = [((cmd, ), '', subprocess2.CalledProcessError(1, '', '', '', ''))] | 752 calls = [((cmd, ), CERR1)] |
742 if issue: | 753 if issue: |
743 calls.extend([ | 754 calls.extend([ |
744 ((['git', 'config', 'branch.master.gerritserver'],), ''), | 755 ((['git', 'config', 'branch.master.gerritserver'],), ''), |
745 ]) | 756 ]) |
746 calls.extend([ | 757 calls.extend([ |
747 ((['git', 'config', 'branch.master.merge'],), 'refs/heads/master'), | 758 ((['git', 'config', 'branch.master.merge'],), 'refs/heads/master'), |
748 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 759 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
749 ((['git', 'config', 'remote.origin.url'],), | 760 ((['git', 'config', 'remote.origin.url'],), |
750 'https://chromium.googlesource.com/my/repo'), | 761 'https://chromium.googlesource.com/my/repo'), |
751 ((['git', 'config', 'remote.origin.url'],), | 762 ((['git', 'config', 'remote.origin.url'],), |
752 'https://chromium.googlesource.com/my/repo'), | 763 'https://chromium.googlesource.com/my/repo'), |
753 ]) | 764 ]) |
754 return calls | 765 return calls |
755 | 766 |
756 @classmethod | 767 @classmethod |
757 def _gerrit_base_calls(cls, issue=None): | 768 def _gerrit_base_calls(cls, issue=None): |
758 return [ | 769 return [ |
759 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 770 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
760 ((['git', 'config', '--int', '--get', | 771 ((['git', 'config', '--int', 'branch.master.git-cl-similarity'],), |
761 'branch.master.git-cl-similarity'],), ''), | 772 CERR1), |
762 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 773 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
763 ((['git', 'config', '--int', '--get', | 774 ((['git', 'config', '--bool', 'branch.master.git-find-copies'],), |
764 'branch.master.git-find-copies'],), ''), | 775 CERR1), |
765 ] + cls._is_gerrit_calls(True) + [ | 776 ] + cls._is_gerrit_calls(True) + [ |
766 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 777 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
767 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 778 ((['git', 'config', '--int', 'branch.master.rietveldissue'],), CERR1), |
768 ((['git', 'config', 'branch.master.gerritissue'],), | 779 ((['git', 'config', '--int', 'branch.master.gerritissue'],), |
769 '' if issue is None else str(issue)), | 780 CERR1 if issue is None else str(issue)), |
770 ((['git', 'config', 'branch.master.merge'],), 'refs/heads/master'), | 781 ((['git', 'config', 'branch.master.merge'],), 'refs/heads/master'), |
771 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 782 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
772 ((['get_or_create_merge_base', 'master', | 783 ((['get_or_create_merge_base', 'master', |
773 'refs/remotes/origin/master'],), | 784 'refs/remotes/origin/master'],), |
774 'fake_ancestor_sha'), | 785 'fake_ancestor_sha'), |
775 # Calls to verify branch point is ancestor | 786 # Calls to verify branch point is ancestor |
776 ] + (cls._gerrit_ensure_auth_calls(issue=issue) + | 787 ] + (cls._gerrit_ensure_auth_calls(issue=issue) + |
777 cls._git_sanity_checks('fake_ancestor_sha', 'master', | 788 cls._git_sanity_checks('fake_ancestor_sha', 'master', |
778 get_remote_branch=False)) + [ | 789 get_remote_branch=False)) + [ |
779 ((['git', 'rev-parse', '--show-cdup'],), ''), | 790 ((['git', 'rev-parse', '--show-cdup'],), ''), |
780 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 791 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
781 | 792 |
782 ((['git', | 793 ((['git', |
783 'diff', '--name-status', '--no-renames', '-r', | 794 'diff', '--name-status', '--no-renames', '-r', |
784 'fake_ancestor_sha...', '.'],), | 795 'fake_ancestor_sha...', '.'],), |
785 'M\t.gitignore\n'), | 796 'M\t.gitignore\n'), |
786 ((['git', 'config', 'branch.master.gerritpatchset'],), ''), | 797 ((['git', 'config', '--int', 'branch.master.gerritpatchset'],), CERR1), |
787 ] + ([] if issue else [ | 798 ] + ([] if issue else [ |
788 ((['git', | 799 ((['git', |
789 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), | 800 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), |
790 'foo'), | 801 'foo'), |
791 ]) + [ | 802 ]) + [ |
792 ((['git', 'config', 'user.email'],), 'me@example.com'), | 803 ((['git', 'config', 'user.email'],), 'me@example.com'), |
793 ((['git', | 804 ((['git', |
794 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 805 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
795 '-l100000', '-C50', 'fake_ancestor_sha', 'HEAD'],), | 806 '-l100000', '-C50', 'fake_ancestor_sha', 'HEAD'],), |
796 '+dat'), | 807 '+dat'), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 'remote: Processing changes: new: 1, done\n' | 906 'remote: Processing changes: new: 1, done\n' |
896 'remote:\n' | 907 'remote:\n' |
897 'remote: New Changes:\n' | 908 'remote: New Changes:\n' |
898 'remote: https://chromium-review.googlesource.com/123456 XXX.\n' | 909 'remote: https://chromium-review.googlesource.com/123456 XXX.\n' |
899 'remote:\n' | 910 'remote:\n' |
900 'To https://chromium.googlesource.com/yyy/zzz\n' | 911 'To https://chromium.googlesource.com/yyy/zzz\n' |
901 ' * [new branch] hhhh -> refs/for/refs/heads/master\n')), | 912 ' * [new branch] hhhh -> refs/for/refs/heads/master\n')), |
902 ] | 913 ] |
903 if squash: | 914 if squash: |
904 calls += [ | 915 calls += [ |
905 ((['git', 'config', 'branch.master.gerritissue', '123456'],), ''), | 916 ((['git', 'config', '--int', 'branch.master.gerritissue', '123456'],), |
| 917 ''), |
906 ((['git', 'config', 'branch.master.gerritserver', | 918 ((['git', 'config', 'branch.master.gerritserver', |
907 'https://chromium-review.googlesource.com'],), ''), | 919 'https://chromium-review.googlesource.com'],), ''), |
908 ((['git', 'config', 'branch.master.gerritsquashhash', | 920 ((['git', 'config', 'branch.master.gerritsquashhash', |
909 'abcdef0123456789'],), ''), | 921 'abcdef0123456789'],), ''), |
910 ] | 922 ] |
911 calls += cls._git_post_upload_calls() | 923 calls += cls._git_post_upload_calls() |
912 return calls | 924 return calls |
913 | 925 |
914 def _run_gerrit_upload_test( | 926 def _run_gerrit_upload_test( |
915 self, | 927 self, |
916 upload_args, | 928 upload_args, |
917 description, | 929 description, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 }) | 1270 }) |
1259 self.mock(git_cl.Changelist, 'GetDescription', | 1271 self.mock(git_cl.Changelist, 'GetDescription', |
1260 lambda *args: 'Description') | 1272 lambda *args: 'Description') |
1261 self.mock(git_cl, 'IsGitVersionAtLeast', lambda *args: True) | 1273 self.mock(git_cl, 'IsGitVersionAtLeast', lambda *args: True) |
1262 | 1274 |
1263 self.calls = self.calls or [] | 1275 self.calls = self.calls or [] |
1264 if not force_codereview: | 1276 if not force_codereview: |
1265 # These calls detect codereview to use. | 1277 # These calls detect codereview to use. |
1266 self.calls += [ | 1278 self.calls += [ |
1267 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 1279 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
1268 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 1280 ((['git', 'config', '--int', 'branch.master.rietveldissue'],), CERR1), |
1269 ((['git', 'config', 'branch.master.gerritissue'],), ''), | 1281 ((['git', 'config', '--int', 'branch.master.gerritissue'],), CERR1), |
1270 ((['git', 'config', 'rietveld.autoupdate'],), ''), | 1282 ((['git', 'config', 'rietveld.autoupdate'],), CERR1), |
1271 ] | 1283 ] |
1272 | 1284 |
1273 if is_gerrit: | 1285 if is_gerrit: |
1274 if not force_codereview: | 1286 if not force_codereview: |
1275 self.calls += [ | 1287 self.calls += [ |
1276 ((['git', 'config', 'gerrit.host'],), 'true'), | 1288 ((['git', 'config', 'gerrit.host'],), 'true'), |
1277 ] | 1289 ] |
1278 else: | 1290 else: |
1279 self.calls += [ | 1291 self.calls += [ |
1280 ((['git', 'config', 'gerrit.host'],), ''), | 1292 ((['git', 'config', 'gerrit.host'],), CERR1), |
1281 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 1293 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
1282 ((['git', 'rev-parse', '--show-cdup'],), ''), | 1294 ((['git', 'rev-parse', '--show-cdup'],), ''), |
1283 ((['sed', '-e', 's|^--- a/|--- |; s|^+++ b/|+++ |'],), ''), | 1295 ((['sed', '-e', 's|^--- a/|--- |; s|^+++ b/|+++ |'],), ''), |
1284 ] | 1296 ] |
1285 | 1297 |
1286 def _common_patch_successful(self): | 1298 def _common_patch_successful(self): |
1287 self._patch_common() | 1299 self._patch_common() |
1288 self.calls += [ | 1300 self.calls += [ |
1289 ((['git', 'apply', '--index', '-p0', '--3way'],), ''), | 1301 ((['git', 'apply', '--index', '-p0', '--3way'],), ''), |
1290 ((['git', 'commit', '-m', | 1302 ((['git', 'commit', '-m', |
1291 'Description\n\n' + | 1303 'Description\n\n' + |
1292 'patch from issue 123456 at patchset 60001 ' + | 1304 'patch from issue 123456 at patchset 60001 ' + |
1293 '(http://crrev.com/123456#ps60001)'],), ''), | 1305 '(http://crrev.com/123456#ps60001)'],), ''), |
1294 ((['git', 'config', 'branch.master.rietveldissue', '123456'],), ''), | 1306 ((['git', 'config', '--int', 'branch.master.rietveldissue', '123456'],), |
1295 ((['git', 'config', 'branch.master.rietveldserver'],), ''), | 1307 ''), |
| 1308 ((['git', 'config', 'branch.master.rietveldserver'],), CERR1), |
1296 ((['git', 'config', 'branch.master.rietveldserver', | 1309 ((['git', 'config', 'branch.master.rietveldserver', |
1297 'https://codereview.example.com'],), ''), | 1310 'https://codereview.example.com'],), ''), |
1298 ((['git', 'config', 'branch.master.rietveldpatchset', '60001'],), ''), | 1311 ((['git', 'config', '--int', 'branch.master.rietveldpatchset', '60001'],), |
| 1312 ''), |
1299 ] | 1313 ] |
1300 | 1314 |
1301 def test_patch_successful(self): | 1315 def test_patch_successful(self): |
1302 self._common_patch_successful() | 1316 self._common_patch_successful() |
1303 self.assertEqual(git_cl.main(['patch', '123456']), 0) | 1317 self.assertEqual(git_cl.main(['patch', '123456']), 0) |
1304 | 1318 |
1305 def test_patch_successful_new_branch(self): | 1319 def test_patch_successful_new_branch(self): |
1306 self.calls = [ ((['git', 'new-branch', 'master'],), ''), ] | 1320 self.calls = [ ((['git', 'new-branch', 'master'],), ''), ] |
1307 self._common_patch_successful() | 1321 self._common_patch_successful() |
1308 self.assertEqual(git_cl.main(['patch', '-b', 'master', '123456']), 0) | 1322 self.assertEqual(git_cl.main(['patch', '-b', 'master', '123456']), 0) |
1309 | 1323 |
1310 def test_patch_conflict(self): | 1324 def test_patch_conflict(self): |
1311 self._patch_common() | 1325 self._patch_common() |
1312 self.calls += [ | 1326 self.calls += [ |
1313 ((['git', 'apply', '--index', '-p0', '--3way'],), '', | 1327 ((['git', 'apply', '--index', '-p0', '--3way'],), CERR1), |
1314 subprocess2.CalledProcessError(1, '', '', '', '')), | |
1315 ] | 1328 ] |
1316 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) | 1329 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) |
1317 | 1330 |
1318 def test_gerrit_patch_successful(self): | 1331 def test_gerrit_patch_successful(self): |
1319 self._patch_common(is_gerrit=True) | 1332 self._patch_common(is_gerrit=True) |
1320 self.calls += [ | 1333 self.calls += [ |
1321 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', | 1334 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', |
1322 'refs/changes/56/123456/7'],), ''), | 1335 'refs/changes/56/123456/7'],), ''), |
1323 ((['git', 'cherry-pick', 'FETCH_HEAD'],), ''), | 1336 ((['git', 'cherry-pick', 'FETCH_HEAD'],), ''), |
1324 ((['git', 'config', 'branch.master.gerritissue', '123456'],), ''), | 1337 ((['git', 'config', '--int', 'branch.master.gerritissue', '123456'],), |
| 1338 ''), |
1325 ((['git', 'config', 'branch.master.gerritserver'],), ''), | 1339 ((['git', 'config', 'branch.master.gerritserver'],), ''), |
1326 ((['git', 'config', 'branch.master.merge'],), 'master'), | 1340 ((['git', 'config', 'branch.master.merge'],), 'master'), |
1327 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 1341 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
1328 ((['git', 'config', 'remote.origin.url'],), | 1342 ((['git', 'config', 'remote.origin.url'],), |
1329 'https://chromium.googlesource.com/my/repo'), | 1343 'https://chromium.googlesource.com/my/repo'), |
1330 ((['git', 'config', 'branch.master.gerritserver', | 1344 ((['git', 'config', 'branch.master.gerritserver', |
1331 'https://chromium-review.googlesource.com'],), ''), | 1345 'https://chromium-review.googlesource.com'],), ''), |
1332 ((['git', 'config', 'branch.master.gerritpatchset', '7'],), ''), | 1346 ((['git', 'config', '--int', 'branch.master.gerritpatchset', '7'],), ''), |
1333 ] | 1347 ] |
1334 self.assertEqual(git_cl.main(['patch', '123456']), 0) | 1348 self.assertEqual(git_cl.main(['patch', '123456']), 0) |
1335 | 1349 |
1336 def test_patch_force_codereview(self): | 1350 def test_patch_force_codereview(self): |
1337 self._patch_common(is_gerrit=True, force_codereview=True) | 1351 self._patch_common(is_gerrit=True, force_codereview=True) |
1338 self.calls += [ | 1352 self.calls += [ |
1339 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', | 1353 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', |
1340 'refs/changes/56/123456/7'],), ''), | 1354 'refs/changes/56/123456/7'],), ''), |
1341 ((['git', 'cherry-pick', 'FETCH_HEAD'],), ''), | 1355 ((['git', 'cherry-pick', 'FETCH_HEAD'],), ''), |
1342 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 1356 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
1343 ((['git', 'config', 'branch.master.gerritissue', '123456'],), ''), | 1357 ((['git', 'config', '--int', 'branch.master.gerritissue', '123456'],), |
| 1358 ''), |
1344 ((['git', 'config', 'branch.master.gerritserver'],), ''), | 1359 ((['git', 'config', 'branch.master.gerritserver'],), ''), |
1345 ((['git', 'config', 'branch.master.merge'],), 'master'), | 1360 ((['git', 'config', 'branch.master.merge'],), 'master'), |
1346 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 1361 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
1347 ((['git', 'config', 'remote.origin.url'],), | 1362 ((['git', 'config', 'remote.origin.url'],), |
1348 'https://chromium.googlesource.com/my/repo'), | 1363 'https://chromium.googlesource.com/my/repo'), |
1349 ((['git', 'config', 'branch.master.gerritserver', | 1364 ((['git', 'config', 'branch.master.gerritserver', |
1350 'https://chromium-review.googlesource.com'],), ''), | 1365 'https://chromium-review.googlesource.com'],), ''), |
1351 ((['git', 'config', 'branch.master.gerritpatchset', '7'],), ''), | 1366 ((['git', 'config', '--int', 'branch.master.gerritpatchset', '7'],), ''), |
1352 ] | 1367 ] |
1353 self.assertEqual(git_cl.main(['patch', '--gerrit', '123456']), 0) | 1368 self.assertEqual(git_cl.main(['patch', '--gerrit', '123456']), 0) |
1354 | 1369 |
1355 def test_gerrit_patch_url_successful(self): | 1370 def test_gerrit_patch_url_successful(self): |
1356 self._patch_common(is_gerrit=True) | 1371 self._patch_common(is_gerrit=True) |
1357 self.calls += [ | 1372 self.calls += [ |
1358 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', | 1373 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', |
1359 'refs/changes/56/123456/1'],), ''), | 1374 'refs/changes/56/123456/1'],), ''), |
1360 ((['git', 'cherry-pick', 'FETCH_HEAD'],), ''), | 1375 ((['git', 'cherry-pick', 'FETCH_HEAD'],), ''), |
1361 ((['git', 'config', 'branch.master.gerritissue', '123456'],), ''), | 1376 ((['git', 'config', '--int', 'branch.master.gerritissue', '123456'],), |
| 1377 ''), |
1362 ((['git', 'config', 'branch.master.gerritserver', | 1378 ((['git', 'config', 'branch.master.gerritserver', |
1363 'https://chromium-review.googlesource.com'],), ''), | 1379 'https://chromium-review.googlesource.com'],), ''), |
1364 ((['git', 'config', 'branch.master.gerritpatchset', '1'],), ''), | 1380 ((['git', 'config', '--int', 'branch.master.gerritpatchset', '1'],), ''), |
1365 ] | 1381 ] |
1366 self.assertEqual(git_cl.main( | 1382 self.assertEqual(git_cl.main( |
1367 ['patch', 'https://chromium-review.googlesource.com/#/c/123456/1']), 0) | 1383 ['patch', 'https://chromium-review.googlesource.com/#/c/123456/1']), 0) |
1368 | 1384 |
1369 def test_gerrit_patch_conflict(self): | 1385 def test_gerrit_patch_conflict(self): |
1370 self._patch_common(is_gerrit=True) | 1386 self._patch_common(is_gerrit=True) |
1371 self.mock(git_cl, 'DieWithError', | 1387 self.mock(git_cl, 'DieWithError', |
1372 lambda msg: self._mocked_call(['DieWithError', msg])) | 1388 lambda msg: self._mocked_call(['DieWithError', msg])) |
1373 class SystemExitMock(Exception): | 1389 class SystemExitMock(Exception): |
1374 pass | 1390 pass |
1375 self.calls += [ | 1391 self.calls += [ |
1376 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', | 1392 ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo', |
1377 'refs/changes/56/123456/1'],), ''), | 1393 'refs/changes/56/123456/1'],), ''), |
1378 ((['git', 'cherry-pick', 'FETCH_HEAD'],), | 1394 ((['git', 'cherry-pick', 'FETCH_HEAD'],), CERR1), |
1379 '', subprocess2.CalledProcessError(1, '', '', '', '')), | 1395 ((['DieWithError', 'Command "git cherry-pick FETCH_HEAD" failed.\n'],), |
1380 ((['DieWithError', 'git cherry-pick FETCH_HEAD" failed.\n'],), | 1396 SystemExitMock()), |
1381 '', SystemExitMock()), | |
1382 ] | 1397 ] |
1383 with self.assertRaises(SystemExitMock): | 1398 with self.assertRaises(SystemExitMock): |
1384 git_cl.main(['patch', | 1399 git_cl.main(['patch', |
1385 'https://chromium-review.googlesource.com/#/c/123456/1']) | 1400 'https://chromium-review.googlesource.com/#/c/123456/1']) |
1386 | 1401 |
1387 def _checkout_calls(self): | 1402 def _checkout_calls(self): |
1388 return [ | 1403 return [ |
1389 ((['git', 'config', '--local', '--get-regexp', | 1404 ((['git', 'config', '--local', '--get-regexp', |
1390 'branch\\..*\\.rietveldissue'], ), | 1405 'branch\\..*\\.rietveldissue'], ), |
1391 ('branch.retrying.rietveldissue 1111111111\n' | 1406 ('branch.retrying.rietveldissue 1111111111\n' |
(...skipping 20 matching lines...) Expand all Loading... |
1412 """Tests git cl checkout <issue>.""" | 1427 """Tests git cl checkout <issue>.""" |
1413 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | 1428 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
1414 self.calls = self._checkout_calls() | 1429 self.calls = self._checkout_calls() |
1415 self.assertEqual(1, git_cl.main(['checkout', '99999'])) | 1430 self.assertEqual(1, git_cl.main(['checkout', '99999'])) |
1416 | 1431 |
1417 def test_checkout_no_branch_issues(self): | 1432 def test_checkout_no_branch_issues(self): |
1418 """Tests git cl checkout <issue>.""" | 1433 """Tests git cl checkout <issue>.""" |
1419 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | 1434 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
1420 self.calls = [ | 1435 self.calls = [ |
1421 ((['git', 'config', '--local', '--get-regexp', | 1436 ((['git', 'config', '--local', '--get-regexp', |
1422 'branch\\..*\\.rietveldissue'], ), '', | 1437 'branch\\..*\\.rietveldissue'], ), CERR1), |
1423 subprocess2.CalledProcessError(1, '', '', '', '')), | |
1424 ((['git', 'config', '--local', '--get-regexp', | 1438 ((['git', 'config', '--local', '--get-regexp', |
1425 'branch\\..*\\.gerritissue'], ), '', | 1439 'branch\\..*\\.gerritissue'], ), CERR1), |
1426 subprocess2.CalledProcessError(1, '', '', '', '')), | |
1427 | |
1428 ] | 1440 ] |
1429 self.assertEqual(1, git_cl.main(['checkout', '99999'])) | 1441 self.assertEqual(1, git_cl.main(['checkout', '99999'])) |
1430 | 1442 |
1431 def _test_gerrit_ensure_authenticated_common(self, auth, | 1443 def _test_gerrit_ensure_authenticated_common(self, auth, |
1432 skip_auth_check=False): | 1444 skip_auth_check=False): |
1433 self.mock(git_cl.gerrit_util, 'CookiesAuthenticator', | 1445 self.mock(git_cl.gerrit_util, 'CookiesAuthenticator', |
1434 CookiesAuthenticatorMockFactory(hosts_with_creds=auth)) | 1446 CookiesAuthenticatorMockFactory(hosts_with_creds=auth)) |
1435 self.mock(git_cl, 'DieWithError', | 1447 self.mock(git_cl, 'DieWithError', |
1436 lambda msg: self._mocked_call(['DieWithError', msg])) | 1448 lambda msg: self._mocked_call(['DieWithError', msg])) |
1437 self.mock(git_cl, 'ask_for_data', | 1449 self.mock(git_cl, 'ask_for_data', |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 def test_gerrit_ensure_authenticated_skipped(self): | 1489 def test_gerrit_ensure_authenticated_skipped(self): |
1478 cl = self._test_gerrit_ensure_authenticated_common( | 1490 cl = self._test_gerrit_ensure_authenticated_common( |
1479 auth={}, skip_auth_check=True) | 1491 auth={}, skip_auth_check=True) |
1480 self.assertIsNone(cl.EnsureAuthenticated(force=False)) | 1492 self.assertIsNone(cl.EnsureAuthenticated(force=False)) |
1481 | 1493 |
1482 def test_cmd_set_commit_rietveld(self): | 1494 def test_cmd_set_commit_rietveld(self): |
1483 self.mock(git_cl._RietveldChangelistImpl, 'SetFlags', | 1495 self.mock(git_cl._RietveldChangelistImpl, 'SetFlags', |
1484 lambda _, v: self._mocked_call(['SetFlags', v])) | 1496 lambda _, v: self._mocked_call(['SetFlags', v])) |
1485 self.calls = [ | 1497 self.calls = [ |
1486 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | 1498 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), |
1487 ((['git', 'config', 'branch.feature.rietveldissue'],), '123'), | 1499 ((['git', 'config', '--int', 'branch.feature.rietveldissue'],), '123'), |
1488 ((['git', 'config', 'rietveld.autoupdate'],), ''), | 1500 ((['git', 'config', 'rietveld.autoupdate'],), ''), |
1489 ((['git', 'config', 'rietveld.server'],), ''), | 1501 ((['git', 'config', 'rietveld.server'],), ''), |
1490 ((['git', 'config', 'rietveld.server'],), ''), | 1502 ((['git', 'config', 'rietveld.server'],), ''), |
1491 ((['git', 'config', 'branch.feature.rietveldserver'],), | 1503 ((['git', 'config', 'branch.feature.rietveldserver'],), |
1492 'https://codereview.chromium.org'), | 1504 'https://codereview.chromium.org'), |
1493 ((['SetFlags', {'commit': '1', 'cq_dry_run': '0'}], ), ''), | 1505 ((['SetFlags', {'commit': '1', 'cq_dry_run': '0'}], ), ''), |
1494 ] | 1506 ] |
1495 self.assertEqual(0, git_cl.main(['set-commit'])) | 1507 self.assertEqual(0, git_cl.main(['set-commit'])) |
1496 | 1508 |
1497 def _cmd_set_commit_gerrit_common(self, vote): | 1509 def _cmd_set_commit_gerrit_common(self, vote): |
1498 self.mock(git_cl.gerrit_util, 'SetReview', | 1510 self.mock(git_cl.gerrit_util, 'SetReview', |
1499 lambda h, i, labels: self._mocked_call( | 1511 lambda h, i, labels: self._mocked_call( |
1500 ['SetReview', h, i, labels])) | 1512 ['SetReview', h, i, labels])) |
1501 self.calls = [ | 1513 self.calls = [ |
1502 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | 1514 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), |
1503 ((['git', 'config', 'branch.feature.rietveldissue'],), ''), | 1515 ((['git', 'config', '--int', 'branch.feature.rietveldissue'],), CERR1), |
1504 ((['git', 'config', 'branch.feature.gerritissue'],), '123'), | 1516 ((['git', 'config', '--int', 'branch.feature.gerritissue'],), '123'), |
1505 ((['git', 'config', 'branch.feature.gerritserver'],), | 1517 ((['git', 'config', 'branch.feature.gerritserver'],), |
1506 'https://chromium-review.googlesource.com'), | 1518 'https://chromium-review.googlesource.com'), |
1507 ((['SetReview', 'chromium-review.googlesource.com', 123, | 1519 ((['SetReview', 'chromium-review.googlesource.com', 123, |
1508 {'Commit-Queue': vote}],), ''), | 1520 {'Commit-Queue': vote}],), ''), |
1509 ] | 1521 ] |
1510 | 1522 |
1511 def test_cmd_set_commit_gerrit_clear(self): | 1523 def test_cmd_set_commit_gerrit_clear(self): |
1512 self._cmd_set_commit_gerrit_common(0) | 1524 self._cmd_set_commit_gerrit_common(0) |
1513 self.assertEqual(0, git_cl.main(['set-commit', '-c'])) | 1525 self.assertEqual(0, git_cl.main(['set-commit', '-c'])) |
1514 | 1526 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 | 1661 |
1650 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | 1662 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
1651 self.mock(git_cl.Changelist, 'GetDescription', | 1663 self.mock(git_cl.Changelist, 'GetDescription', |
1652 lambda *args: current_desc) | 1664 lambda *args: current_desc) |
1653 self.mock(git_cl._GerritChangelistImpl, 'UpdateDescriptionRemote', | 1665 self.mock(git_cl._GerritChangelistImpl, 'UpdateDescriptionRemote', |
1654 UpdateDescriptionRemote) | 1666 UpdateDescriptionRemote) |
1655 self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor) | 1667 self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor) |
1656 | 1668 |
1657 self.calls = [ | 1669 self.calls = [ |
1658 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | 1670 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), |
1659 ((['git', 'config', 'branch.feature.gerritissue'],), '123'), | 1671 ((['git', 'config', '--int', 'branch.feature.gerritissue'],), '123'), |
1660 ((['git', 'config', 'rietveld.autoupdate'],), ''), | 1672 ((['git', 'config', 'rietveld.autoupdate'],), CERR1), |
1661 ((['git', 'config', 'rietveld.bug-prefix'],), ''), | 1673 ((['git', 'config', 'rietveld.bug-prefix'],), CERR1), |
1662 ((['git', 'config', 'core.editor'],), 'vi'), | 1674 ((['git', 'config', 'core.editor'],), 'vi'), |
1663 ] | 1675 ] |
1664 self.assertEqual(0, git_cl.main(['description', '--gerrit'])) | 1676 self.assertEqual(0, git_cl.main(['description', '--gerrit'])) |
1665 | 1677 |
1666 def test_description_set_stdin(self): | 1678 def test_description_set_stdin(self): |
1667 out = StringIO.StringIO() | 1679 out = StringIO.StringIO() |
1668 self.mock(git_cl.sys, 'stdout', out) | 1680 self.mock(git_cl.sys, 'stdout', out) |
1669 | 1681 |
1670 self.mock(git_cl, 'Changelist', ChangelistMock) | 1682 self.mock(git_cl, 'Changelist', ChangelistMock) |
1671 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hi \r\n\t there\n\nman')) | 1683 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hi \r\n\t there\n\nman')) |
1672 | 1684 |
1673 self.assertEqual(0, git_cl.main(['description', '-n', '-'])) | 1685 self.assertEqual(0, git_cl.main(['description', '-n', '-'])) |
1674 self.assertEqual('hi\n\t there\n\nman', ChangelistMock.desc) | 1686 self.assertEqual('hi\n\t there\n\nman', ChangelistMock.desc) |
1675 | 1687 |
1676 def test_archive(self): | 1688 def test_archive(self): |
1677 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | 1689 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
1678 | 1690 |
1679 self.calls = \ | 1691 self.calls = \ |
1680 [((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],), | 1692 [((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],), |
1681 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'), | 1693 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'), |
1682 ((['git', 'config', 'branch.master.rietveldissue'],), '1'), | 1694 ((['git', 'config', '--int', 'branch.master.rietveldissue'],), '1'), |
1683 ((['git', 'config', 'rietveld.autoupdate'],), ''), | 1695 ((['git', 'config', 'rietveld.autoupdate'],), CERR1), |
1684 ((['git', 'config', 'rietveld.server'],), ''), | 1696 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
1685 ((['git', 'config', 'rietveld.server'],), ''), | 1697 ((['git', 'config', '--int', 'branch.foo.rietveldissue'],), '456'), |
1686 ((['git', 'config', 'branch.foo.rietveldissue'],), '456'), | 1698 ((['git', 'config', '--int', 'branch.bar.rietveldissue'],), CERR1), |
1687 ((['git', 'config', 'rietveld.server'],), ''), | 1699 ((['git', 'config', '--int', 'branch.bar.gerritissue'],), '789'), |
1688 ((['git', 'config', 'rietveld.server'],), ''), | |
1689 ((['git', 'config', 'branch.bar.rietveldissue'],), ''), | |
1690 ((['git', 'config', 'branch.bar.gerritissue'],), '789'), | |
1691 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 1700 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
1692 ((['git', 'tag', 'git-cl-archived-456-foo', 'foo'],), ''), | 1701 ((['git', 'tag', 'git-cl-archived-456-foo', 'foo'],), ''), |
1693 ((['git', 'branch', '-D', 'foo'],), '')] | 1702 ((['git', 'branch', '-D', 'foo'],), '')] |
1694 | 1703 |
1695 class MockChangelist(): | 1704 class MockChangelist(): |
1696 def __init__(self, branch, issue): | 1705 def __init__(self, branch, issue): |
1697 self.branch = branch | 1706 self.branch = branch |
1698 self.issue = issue | 1707 self.issue = issue |
1699 def GetBranch(self): | 1708 def GetBranch(self): |
1700 return self.branch | 1709 return self.branch |
1701 def GetIssue(self): | 1710 def GetIssue(self): |
1702 return self.issue | 1711 return self.issue |
1703 | 1712 |
1704 self.mock(git_cl, 'get_cl_statuses', | 1713 self.mock(git_cl, 'get_cl_statuses', |
1705 lambda branches, fine_grained, max_processes: | 1714 lambda branches, fine_grained, max_processes: |
1706 [(MockChangelist('master', 1), 'open'), | 1715 [(MockChangelist('master', 1), 'open'), |
1707 (MockChangelist('foo', 456), 'closed'), | 1716 (MockChangelist('foo', 456), 'closed'), |
1708 (MockChangelist('bar', 789), 'open')]) | 1717 (MockChangelist('bar', 789), 'open')]) |
1709 | 1718 |
1710 self.assertEqual(0, git_cl.main(['archive', '-f'])) | 1719 self.assertEqual(0, git_cl.main(['archive', '-f'])) |
1711 | 1720 |
1712 def test_archive_current_branch_fails(self): | 1721 def test_archive_current_branch_fails(self): |
1713 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) | 1722 self.mock(git_cl.sys, 'stdout', StringIO.StringIO()) |
1714 self.calls = \ | 1723 self.calls = \ |
1715 [((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],), | 1724 [((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],), |
1716 'refs/heads/master'), | 1725 'refs/heads/master'), |
1717 ((['git', 'config', 'branch.master.rietveldissue'],), '1'), | 1726 ((['git', 'config', '--int', 'branch.master.rietveldissue'],), '1'), |
1718 ((['git', 'config', 'rietveld.autoupdate'],), ''), | 1727 ((['git', 'config', 'rietveld.autoupdate'],), CERR1), |
1719 ((['git', 'config', 'rietveld.server'],), ''), | 1728 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
1720 ((['git', 'config', 'rietveld.server'],), ''), | |
1721 ((['git', 'symbolic-ref', 'HEAD'],), 'master')] | 1729 ((['git', 'symbolic-ref', 'HEAD'],), 'master')] |
1722 | 1730 |
1723 class MockChangelist(): | 1731 class MockChangelist(): |
1724 def __init__(self, branch, issue): | 1732 def __init__(self, branch, issue): |
1725 self.branch = branch | 1733 self.branch = branch |
1726 self.issue = issue | 1734 self.issue = issue |
1727 def GetBranch(self): | 1735 def GetBranch(self): |
1728 return self.branch | 1736 return self.branch |
1729 def GetIssue(self): | 1737 def GetIssue(self): |
1730 return self.issue | 1738 return self.issue |
1731 | 1739 |
1732 self.mock(git_cl, 'get_cl_statuses', | 1740 self.mock(git_cl, 'get_cl_statuses', |
1733 lambda branches, fine_grained, max_processes: | 1741 lambda branches, fine_grained, max_processes: |
1734 [(MockChangelist('master', 1), 'closed')]) | 1742 [(MockChangelist('master', 1), 'closed')]) |
1735 | 1743 |
1736 self.assertEqual(1, git_cl.main(['archive', '-f'])) | 1744 self.assertEqual(1, git_cl.main(['archive', '-f'])) |
1737 | 1745 |
1738 def test_cmd_issue_erase_existing(self): | 1746 def test_cmd_issue_erase_existing(self): |
1739 out = StringIO.StringIO() | 1747 out = StringIO.StringIO() |
1740 self.mock(git_cl.sys, 'stdout', out) | 1748 self.mock(git_cl.sys, 'stdout', out) |
1741 self.calls = [ | 1749 self.calls = [ |
1742 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | 1750 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), |
1743 ((['git', 'config', 'branch.feature.rietveldissue'],), ''), | 1751 ((['git', 'config', '--int', 'branch.feature.rietveldissue'],), CERR1), |
1744 ((['git', 'config', 'branch.feature.gerritissue'],), '123'), | 1752 ((['git', 'config', '--int', 'branch.feature.gerritissue'],), '123'), |
| 1753 # Let this command raise exception (retcode=1) - it should be ignored. |
| 1754 ((['git', 'config', '--unset', 'branch.feature.last-upload-hash'],), |
| 1755 CERR1), |
1745 ((['git', 'config', '--unset', 'branch.feature.gerritissue'],), ''), | 1756 ((['git', 'config', '--unset', 'branch.feature.gerritissue'],), ''), |
1746 ((['git', 'config', '--unset', 'branch.feature.gerritpatchset'],), ''), | 1757 ((['git', 'config', '--unset', 'branch.feature.gerritpatchset'],), ''), |
1747 # Let this command raise exception (retcode=1) - it should be ignored. | |
1748 ((['git', 'config', '--unset', 'branch.feature.last-upload-hash'],), | |
1749 '', subprocess2.CalledProcessError(1, '', '', '', '')), | |
1750 ((['git', 'config', '--unset', 'branch.feature.gerritserver'],), ''), | 1758 ((['git', 'config', '--unset', 'branch.feature.gerritserver'],), ''), |
1751 ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],), | 1759 ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],), |
1752 ''), | 1760 ''), |
1753 ] | 1761 ] |
1754 self.assertEqual(0, git_cl.main(['issue', '0'])) | 1762 self.assertEqual(0, git_cl.main(['issue', '0'])) |
1755 | 1763 |
1756 def test_git_cl_try_default(self): | 1764 def test_git_cl_try_default(self): |
1757 self.mock(git_cl.Changelist, 'GetChange', | 1765 self.mock(git_cl.Changelist, 'GetChange', |
1758 lambda _, *a: ( | 1766 lambda _, *a: ( |
1759 self._mocked_call(['GetChange']+list(a)))) | 1767 self._mocked_call(['GetChange']+list(a)))) |
1760 self.mock(git_cl.presubmit_support, 'DoGetTryMasters', | 1768 self.mock(git_cl.presubmit_support, 'DoGetTryMasters', |
1761 lambda *_, **__: ( | 1769 lambda *_, **__: ( |
1762 self._mocked_call(['DoGetTryMasters']))) | 1770 self._mocked_call(['DoGetTryMasters']))) |
1763 self.mock(git_cl.presubmit_support, 'DoGetTrySlaves', | 1771 self.mock(git_cl.presubmit_support, 'DoGetTrySlaves', |
1764 lambda *_, **__: ( | 1772 lambda *_, **__: ( |
1765 self._mocked_call(['DoGetTrySlaves']))) | 1773 self._mocked_call(['DoGetTrySlaves']))) |
1766 self.mock(git_cl._RietveldChangelistImpl, 'SetCQState', | 1774 self.mock(git_cl._RietveldChangelistImpl, 'SetCQState', |
1767 lambda _, s: self._mocked_call(['SetCQState', s])) | 1775 lambda _, s: self._mocked_call(['SetCQState', s])) |
1768 self.calls = [ | 1776 self.calls = [ |
1769 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | 1777 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), |
1770 ((['git', 'config', 'branch.feature.rietveldissue'],), '123'), | 1778 ((['git', 'config', '--int', 'branch.feature.rietveldissue'],), '123'), |
1771 ((['git', 'config', 'rietveld.autoupdate'],), ''), | 1779 ((['git', 'config', 'rietveld.autoupdate'],), ''), |
1772 ((['git', 'config', 'rietveld.server'],), | 1780 ((['git', 'config', 'rietveld.server'],), |
1773 'https://codereview.chromium.org'), | 1781 'https://codereview.chromium.org'), |
1774 ((['git', 'config', 'branch.feature.rietveldserver'],), ''), | 1782 ((['git', 'config', 'branch.feature.rietveldserver'],), ''), |
1775 ((['git', 'config', 'branch.feature.merge'],), 'feature'), | 1783 ((['git', 'config', 'branch.feature.merge'],), 'feature'), |
1776 ((['git', 'config', 'branch.feature.remote'],), 'origin'), | 1784 ((['git', 'config', 'branch.feature.remote'],), 'origin'), |
1777 ((['get_or_create_merge_base', 'feature', 'feature'],), | 1785 ((['get_or_create_merge_base', 'feature', 'feature'],), |
1778 'fake_ancestor_sha'), | 1786 'fake_ancestor_sha'), |
1779 ((['GetChange', 'fake_ancestor_sha', None], ), | 1787 ((['GetChange', 'fake_ancestor_sha', None], ), |
1780 git_cl.presubmit_support.GitChange( | 1788 git_cl.presubmit_support.GitChange( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), | 1841 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), |
1834 ''), | 1842 ''), |
1835 ] | 1843 ] |
1836 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) | 1844 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) |
1837 | 1845 |
1838 | 1846 |
1839 if __name__ == '__main__': | 1847 if __name__ == '__main__': |
1840 git_cl.logging.basicConfig( | 1848 git_cl.logging.basicConfig( |
1841 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1849 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
1842 unittest.main() | 1850 unittest.main() |
OLD | NEW |