Chromium Code Reviews| 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 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 '@%d Expected: %r Actual: %r' % ( | 90 '@%d Expected: %r Actual: %r' % ( |
| 91 self._calls_done, expected_args, args)) | 91 self._calls_done, expected_args, args)) |
| 92 self._calls_done += 1 | 92 self._calls_done += 1 |
| 93 return result | 93 return result |
| 94 | 94 |
| 95 @classmethod | 95 @classmethod |
| 96 def _upload_calls(cls, similarity, find_copies): | 96 def _upload_calls(cls, similarity, find_copies): |
| 97 return (cls._git_base_calls(similarity, find_copies) + | 97 return (cls._git_base_calls(similarity, find_copies) + |
| 98 cls._git_upload_calls()) | 98 cls._git_upload_calls()) |
| 99 | 99 |
| 100 @staticmethod | 100 @classmethod |
| 101 def _git_base_calls(similarity, find_copies): | 101 def _git_base_calls(cls, similarity, find_copies): |
| 102 if similarity is None: | 102 if similarity is None: |
| 103 similarity = '50' | 103 similarity = '50' |
| 104 similarity_call = ((['git', 'config', '--int', '--get', | 104 similarity_call = ((['git', 'config', '--int', '--get', |
| 105 'branch.master.git-cl-similarity'],), '') | 105 'branch.master.git-cl-similarity'],), '') |
| 106 else: | 106 else: |
| 107 similarity_call = ((['git', 'config', '--int', | 107 similarity_call = ((['git', 'config', '--int', |
| 108 'branch.master.git-cl-similarity', similarity],), '') | 108 'branch.master.git-cl-similarity', similarity],), '') |
| 109 | 109 |
| 110 if find_copies is None: | 110 if find_copies is None: |
| 111 find_copies = True | 111 find_copies = True |
| 112 find_copies_call = ((['git', 'config', '--int', '--get', | 112 find_copies_call = ((['git', 'config', '--int', '--get', |
| 113 'branch.master.git-find-copies'],), '') | 113 'branch.master.git-find-copies'],), '') |
| 114 else: | 114 else: |
| 115 val = str(int(find_copies)) | 115 val = str(int(find_copies)) |
| 116 find_copies_call = ((['git', 'config', '--int', | 116 find_copies_call = ((['git', 'config', '--int', |
| 117 'branch.master.git-find-copies', val],), '') | 117 'branch.master.git-find-copies', val],), '') |
| 118 | 118 |
| 119 if find_copies: | 119 if find_copies: |
| 120 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', | 120 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', |
| 121 '--find-copies-harder', '-l100000', '-C'+similarity, | 121 '--find-copies-harder', '-l100000', '-C'+similarity, |
| 122 'master...'],), '+dat') | 122 'fake_ancestor_sha'],), '+dat') |
| 123 else: | 123 else: |
| 124 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', | 124 stat_call = ((['git', 'diff', '--no-ext-diff', '--stat', |
| 125 '-M'+similarity, 'master...'],), '+dat') | 125 '-M'+similarity, 'fake_ancestor_sha'],), '+dat') |
| 126 | 126 |
| 127 return [ | 127 return [ |
| 128 ((['git', 'config', 'gerrit.host'],), ''), | 128 ((['git', 'config', 'gerrit.host'],), ''), |
| 129 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 129 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
| 130 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 130 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 131 similarity_call, | 131 similarity_call, |
| 132 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 132 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 133 find_copies_call, | 133 find_copies_call, |
| 134 ((['git', 'update-index', '--refresh', '-q'],), ''), | 134 ((['git', 'update-index', '--refresh', '-q'],), ''), |
| 135 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), | 135 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), |
| 136 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 136 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 137 ((['git', 'config', 'branch.master.merge'],), 'master'), | 137 ((['git', 'config', 'branch.master.merge'],), 'master'), |
| 138 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 138 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
| 139 ((['git', 'merge-base', 'master', 'HEAD'],), 'fake_ancestor_sha'), | |
| 140 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ | |
| 139 ((['git', 'rev-parse', '--show-cdup'],), ''), | 141 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 140 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 142 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
| 141 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), | 143 ((['git', 'diff', '--name-status', '-r', 'fake_ancestor_sha...', '.'],), |
| 142 'M\t.gitignore\n'), | 144 'M\t.gitignore\n'), |
| 143 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 145 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
| 144 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 146 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
| 145 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), | 147 ((['git', 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), |
| 148 'foo'), | |
| 146 ((['git', 'config', 'user.email'],), 'me@example.com'), | 149 ((['git', 'config', 'user.email'],), 'me@example.com'), |
| 147 stat_call, | 150 stat_call, |
| 148 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), 'desc\n'), | 151 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| 152 'desc\n'), | |
| 149 ] | 153 ] |
| 150 | 154 |
| 151 @staticmethod | 155 @classmethod |
| 152 def _git_upload_calls(): | 156 def _git_upload_calls(cls): |
| 153 return [ | 157 return [ |
| 154 ((['git', 'config', 'rietveld.cc'],), ''), | 158 ((['git', 'config', 'rietveld.cc'],), ''), |
| 155 ((['git', 'config', 'branch.master.base-url'],), ''), | 159 ((['git', 'config', 'branch.master.base-url'],), ''), |
| 156 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), | 160 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), |
| 157 (('', None), 0)), | 161 (('', None), 0)), |
| 158 ((['git', 'rev-parse', '--show-cdup'],), ''), | 162 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 159 ((['git', 'svn', 'info'],), ''), | 163 ((['git', 'svn', 'info'],), ''), |
| 160 ((['git', 'config', 'branch.master.rietveldissue', '1'],), ''), | 164 ((['git', 'config', 'branch.master.rietveldissue', '1'],), ''), |
| 161 ((['git', 'config', 'branch.master.rietveldserver', | 165 ((['git', 'config', 'branch.master.rietveldserver', |
| 162 'https://codereview.example.com'],), ''), | 166 'https://codereview.example.com'],), ''), |
| 163 ((['git', 'config', 'branch.master.rietveldpatchset', '2'],), ''), | 167 ((['git', 'config', 'branch.master.rietveldpatchset', '2'],), ''), |
| 164 ] | 168 ] |
| 165 | 169 |
| 170 @staticmethod | |
| 171 def _git_sanity_checks(diff_base, working_branch): | |
| 172 fake_ancestor = 'fake_ancestor' | |
| 173 fake_cl = 'fake_cl_for_patch' | |
| 174 return [ | |
| 175 # Calls to verify branch point is ancestor | |
| 176 ((['git', 'rev-parse', '--verify', diff_base],), fake_ancestor), | |
| 177 ((['git', 'merge-base', fake_ancestor, 'HEAD'],), fake_ancestor), | |
| 178 ((['git', 'rev-list', '^' + fake_ancestor, 'HEAD'],), fake_cl), | |
| 179 # Mock a config miss (error code 1) | |
| 180 ((['git', 'config', 'depottools.remotebranch'],), (((''), None), 1)), | |
|
iannucci
2012/11/02 00:30:05
Too much parens!
Isaac (away)
2012/11/02 00:50:03
Nice catch, done.
| |
| 181 # Call to GetRemoteBranch() | |
| 182 ((['git', 'config', 'branch.%s.merge' % working_branch],), | |
| 183 'refs/heads/master'), | |
| 184 ((['git', 'config', 'branch.%s.remote' % working_branch],), 'origin'), | |
| 185 ((['git', 'rev-list', '^' + fake_ancestor, | |
| 186 'refs/remotes/origin/master'],), ''), | |
| 187 ] | |
| 188 | |
| 166 @classmethod | 189 @classmethod |
| 167 def _dcommit_calls_1(cls): | 190 def _dcommit_calls_1(cls): |
| 168 return [ | 191 return [ |
| 169 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), | 192 ((['git', 'config', '--get-regexp', '^svn-remote\\.'],), |
| 170 ((('svn-remote.svn.url svn://svn.chromium.org/chrome\n' | 193 ((('svn-remote.svn.url svn://svn.chromium.org/chrome\n' |
| 171 'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'), | 194 'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'), |
| 172 None), | 195 None), |
| 173 0)), | 196 0)), |
| 174 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 197 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
| 175 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), | 198 ((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'), |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 186 'refs/remotes/origin/master^!'],), ''), | 209 'refs/remotes/origin/master^!'],), ''), |
| 187 ((['git', 'update-index', '--refresh', '-q'],), ''), | 210 ((['git', 'update-index', '--refresh', '-q'],), ''), |
| 188 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), | 211 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), |
| 189 ((['git', 'rev-list', '^refs/heads/working', | 212 ((['git', 'rev-list', '^refs/heads/working', |
| 190 'refs/remotes/origin/master'],), | 213 'refs/remotes/origin/master'],), |
| 191 ''), | 214 ''), |
| 192 ((['git', 'log', '--grep=^git-svn-id:', '-1', '--pretty=format:%H'],), | 215 ((['git', 'log', '--grep=^git-svn-id:', '-1', '--pretty=format:%H'],), |
| 193 '3fc18b62c4966193eb435baabe2d18a3810ec82e'), | 216 '3fc18b62c4966193eb435baabe2d18a3810ec82e'), |
| 194 ((['git', 'rev-list', '^3fc18b62c4966193eb435baabe2d18a3810ec82e', | 217 ((['git', 'rev-list', '^3fc18b62c4966193eb435baabe2d18a3810ec82e', |
| 195 'refs/remotes/origin/master'],), ''), | 218 'refs/remotes/origin/master'],), ''), |
| 219 ((['git', 'merge-base', 'refs/remotes/origin/master', 'HEAD'],), | |
| 220 'fake_ancestor_sha'), | |
| 196 ] | 221 ] |
| 197 | 222 |
| 198 @classmethod | 223 @classmethod |
| 199 def _dcommit_calls_normal(cls): | 224 def _dcommit_calls_normal(cls): |
| 200 return [ | 225 return [ |
| 201 ((['git', 'rev-parse', '--show-cdup'],), ''), | 226 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 202 ((['git', 'rev-parse', 'HEAD'],), | 227 ((['git', 'rev-parse', 'HEAD'],), |
| 203 '00ff397798ea57439712ed7e04ab96e13969ef40'), | 228 '00ff397798ea57439712ed7e04ab96e13969ef40'), |
| 204 ((['git', 'diff', '--name-status', '-r', 'refs/remotes/origin/master...', | 229 ((['git', 'diff', '--name-status', '-r', 'fake_ancestor_sha...', |
| 205 '.'],), | 230 '.'],), |
| 206 'M\tPRESUBMIT.py'), | 231 'M\tPRESUBMIT.py'), |
| 207 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), | 232 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), |
| 208 ((['git', 'config', 'branch.working.rietveldpatchset'],), '31137'), | 233 ((['git', 'config', 'branch.working.rietveldpatchset'],), '31137'), |
| 209 ((['git', 'config', 'branch.working.rietveldserver'],), | 234 ((['git', 'config', 'branch.working.rietveldserver'],), |
| 210 'codereview.example.com'), | 235 'codereview.example.com'), |
| 211 ((['git', 'config', 'user.email'],), 'author@example.com'), | 236 ((['git', 'config', 'user.email'],), 'author@example.com'), |
| 212 ((['git', 'config', 'rietveld.tree-status-url'],), ''), | 237 ((['git', 'config', 'rietveld.tree-status-url'],), ''), |
| 213 ] | 238 ] |
| 214 | 239 |
| 215 @classmethod | 240 @classmethod |
| 216 def _dcommit_calls_bypassed(cls): | 241 def _dcommit_calls_bypassed(cls): |
| 217 return [ | 242 return [ |
| 218 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), | 243 ((['git', 'config', 'branch.working.rietveldissue'],), '12345'), |
| 219 ((['git', 'config', 'branch.working.rietveldserver'],), | 244 ((['git', 'config', 'branch.working.rietveldserver'],), |
| 220 'codereview.example.com'), | 245 'codereview.example.com'), |
| 221 (('GitClHooksBypassedCommit', | 246 (('GitClHooksBypassedCommit', |
| 222 'Issue https://codereview.example.com/12345 bypassed hook when ' | 247 'Issue https://codereview.example.com/12345 bypassed hook when ' |
| 223 'committing'), None), | 248 'committing'), None), |
| 224 ] | 249 ] |
| 225 | 250 |
| 226 @classmethod | 251 @classmethod |
| 227 def _dcommit_calls_3(cls): | 252 def _dcommit_calls_3(cls): |
| 228 return [ | 253 return [ |
| 229 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 254 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 230 '-l100000', '-C50', 'refs/remotes/origin/master', | 255 '-l100000', '-C50', 'fake_ancestor_sha', |
| 231 'refs/heads/working'],), | 256 'refs/heads/working'],), |
| 232 (' PRESUBMIT.py | 2 +-\n' | 257 (' PRESUBMIT.py | 2 +-\n' |
| 233 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), | 258 ' 1 files changed, 1 insertions(+), 1 deletions(-)\n')), |
| 234 (('About to commit; enter to confirm.',), None), | 259 (('About to commit; enter to confirm.',), None), |
| 235 ((['git', 'show-ref', '--quiet', '--verify', | 260 ((['git', 'show-ref', '--quiet', '--verify', |
| 236 'refs/heads/git-cl-commit'],), | 261 'refs/heads/git-cl-commit'],), |
| 237 (('', None), 0)), | 262 (('', None), 0)), |
| 238 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), | 263 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), |
| 239 ((['git', 'show-ref', '--quiet', '--verify', | 264 ((['git', 'show-ref', '--quiet', '--verify', |
| 240 'refs/heads/git-cl-cherry-pick'],), ''), | 265 'refs/heads/git-cl-cherry-pick'],), ''), |
| 241 ((['git', 'rev-parse', '--show-cdup'],), '\n'), | 266 ((['git', 'rev-parse', '--show-cdup'],), '\n'), |
| 242 ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), | 267 ((['git', 'checkout', '-q', '-b', 'git-cl-commit'],), ''), |
| 243 ((['git', 'reset', '--soft', 'refs/remotes/origin/master'],), ''), | 268 ((['git', 'reset', '--soft', 'fake_ancestor_sha'],), ''), |
| 244 ((['git', 'commit', '-m', | 269 ((['git', 'commit', '-m', |
| 245 'Issue: 12345\n\nReview URL: https://codereview.example.com/12345'],), | 270 'Issue: 12345\n\nReview URL: https://codereview.example.com/12345'],), |
| 246 ''), | 271 ''), |
| 247 ((['git', 'svn', 'dcommit', '-C50', '--no-rebase', '--rmdir'],), | 272 ((['git', 'svn', 'dcommit', '-C50', '--no-rebase', '--rmdir'],), |
| 248 (('', None), 0)), | 273 (('', None), 0)), |
| 249 ((['git', 'checkout', '-q', 'working'],), ''), | 274 ((['git', 'checkout', '-q', 'working'],), ''), |
| 250 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), | 275 ((['git', 'branch', '-D', 'git-cl-commit'],), ''), |
| 251 ] | 276 ] |
| 252 | 277 |
| 253 @staticmethod | 278 @staticmethod |
| 254 def _cmd_line(description, args, similarity, find_copies): | 279 def _cmd_line(description, args, similarity, find_copies): |
| 255 """Returns the upload command line passed to upload.RealMain().""" | 280 """Returns the upload command line passed to upload.RealMain().""" |
| 256 return [ | 281 return [ |
| 257 'upload', '--assume_yes', '--server', | 282 'upload', '--assume_yes', '--server', |
| 258 'https://codereview.example.com', | 283 'https://codereview.example.com', |
| 259 '--message', description | 284 '--message', description |
| 260 ] + args + [ | 285 ] + args + [ |
| 261 '--cc', 'joe@example.com', | 286 '--cc', 'joe@example.com', |
| 262 '--git_similarity', similarity or '50' | 287 '--git_similarity', similarity or '50' |
| 263 ] + (['--git_no_find_copies'] if find_copies == False else []) + [ | 288 ] + (['--git_no_find_copies'] if find_copies == False else []) + [ |
| 264 'master...' | 289 'fake_ancestor_sha' |
| 265 ] | 290 ] |
| 266 | 291 |
| 267 def _run_reviewer_test( | 292 def _run_reviewer_test( |
| 268 self, | 293 self, |
| 269 upload_args, | 294 upload_args, |
| 270 expected_description, | 295 expected_description, |
| 271 returned_description, | 296 returned_description, |
| 272 final_description, | 297 final_description, |
| 273 reviewers): | 298 reviewers): |
| 274 """Generic reviewer test framework.""" | 299 """Generic reviewer test framework.""" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 self.mock(sys, 'stderr', mock) | 409 self.mock(sys, 'stderr', mock) |
| 385 git_cl.main(['upload', '--send-mail']) | 410 git_cl.main(['upload', '--send-mail']) |
| 386 self.fail() | 411 self.fail() |
| 387 except SystemExit: | 412 except SystemExit: |
| 388 self.assertEquals( | 413 self.assertEquals( |
| 389 'Must specify reviewers to send email.\n', mock.buf.getvalue()) | 414 'Must specify reviewers to send email.\n', mock.buf.getvalue()) |
| 390 | 415 |
| 391 def test_dcommit(self): | 416 def test_dcommit(self): |
| 392 self.calls = ( | 417 self.calls = ( |
| 393 self._dcommit_calls_1() + | 418 self._dcommit_calls_1() + |
| 419 self._git_sanity_checks('fake_ancestor_sha', 'working') + | |
| 394 self._dcommit_calls_normal() + | 420 self._dcommit_calls_normal() + |
| 395 self._dcommit_calls_3()) | 421 self._dcommit_calls_3()) |
| 396 git_cl.main(['dcommit']) | 422 git_cl.main(['dcommit']) |
| 397 | 423 |
| 398 def test_dcommit_bypass_hooks(self): | 424 def test_dcommit_bypass_hooks(self): |
| 399 self.calls = ( | 425 self.calls = ( |
| 400 self._dcommit_calls_1() + | 426 self._dcommit_calls_1() + |
| 401 self._dcommit_calls_bypassed() + | 427 self._dcommit_calls_bypassed() + |
| 402 self._dcommit_calls_3()) | 428 self._dcommit_calls_3()) |
| 403 git_cl.main(['dcommit', '--bypass-hooks']) | 429 git_cl.main(['dcommit', '--bypass-hooks']) |
| 404 | 430 |
| 405 | 431 |
| 406 @staticmethod | 432 @classmethod |
| 407 def _gerrit_base_calls(): | 433 def _gerrit_base_calls(cls): |
| 408 return [ | 434 return [ |
| 409 ((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'), | 435 ((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'), |
| 410 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), | 436 ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), |
| 411 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 437 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 412 ((['git', 'config', '--int', '--get', | 438 ((['git', 'config', '--int', '--get', |
| 413 'branch.master.git-cl-similarity'],), ''), | 439 'branch.master.git-cl-similarity'],), ''), |
| 414 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 440 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 415 ((['git', 'config', '--int', '--get', | 441 ((['git', 'config', '--int', '--get', |
| 416 'branch.master.git-find-copies'],), ''), | 442 'branch.master.git-find-copies'],), ''), |
| 417 ((['git', 'update-index', '--refresh', '-q'],), ''), | 443 ((['git', 'update-index', '--refresh', '-q'],), ''), |
| 418 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), | 444 ((['git', 'diff-index', '--name-status', 'HEAD'],), ''), |
| 419 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), | 445 ((['git', 'symbolic-ref', 'HEAD'],), 'master'), |
| 420 ((['git', 'config', 'branch.master.merge'],), 'master'), | 446 ((['git', 'config', 'branch.master.merge'],), 'master'), |
| 421 ((['git', 'config', 'branch.master.remote'],), 'origin'), | 447 ((['git', 'config', 'branch.master.remote'],), 'origin'), |
| 448 ((['git', 'merge-base', 'master', 'HEAD'],), 'fake_ancestor_sha'), | |
| 449 ] + cls._git_sanity_checks('fake_ancestor_sha', 'master') + [ | |
| 422 ((['git', 'rev-parse', '--show-cdup'],), ''), | 450 ((['git', 'rev-parse', '--show-cdup'],), ''), |
| 423 ((['git', 'rev-parse', 'HEAD'],), '12345'), | 451 ((['git', 'rev-parse', 'HEAD'],), '12345'), |
| 424 ((['git', 'diff', '--name-status', '-r', 'master...', '.'],), | 452 ((['git', 'diff', '--name-status', '-r', 'fake_ancestor_sha...', '.'],), |
| 425 'M\t.gitignore\n'), | 453 'M\t.gitignore\n'), |
| 426 ((['git', 'config', 'branch.master.rietveldissue'],), ''), | 454 ((['git', 'config', 'branch.master.rietveldissue'],), ''), |
| 427 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), | 455 ((['git', 'config', 'branch.master.rietveldpatchset'],), ''), |
| 428 ((['git', 'log', '--pretty=format:%s%n%n%b', 'master...'],), 'foo'), | 456 ((['git', 'log', '--pretty=format:%s%n%n%b', 'fake_ancestor_sha...'],), |
| 457 'foo'), | |
| 429 ((['git', 'config', 'user.email'],), 'me@example.com'), | 458 ((['git', 'config', 'user.email'],), 'me@example.com'), |
| 430 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', | 459 ((['git', 'diff', '--no-ext-diff', '--stat', '--find-copies-harder', |
| 431 '-l100000', '-C50', 'master...'],), | 460 '-l100000', '-C50', 'fake_ancestor_sha'],), |
| 432 '+dat'), | 461 '+dat'), |
| 433 ] | 462 ] |
| 434 | 463 |
| 435 @staticmethod | 464 @staticmethod |
| 436 def _gerrit_upload_calls(description, reviewers): | 465 def _gerrit_upload_calls(description, reviewers): |
| 437 calls = [ | 466 calls = [ |
| 438 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), | 467 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| 439 description) | 468 description) |
| 440 ] | 469 ] |
| 441 if git_cl.CHANGE_ID not in description: | 470 if git_cl.CHANGE_ID not in description: |
| 442 calls += [ | 471 calls += [ |
| 443 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), | 472 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| 444 description), | 473 description), |
| 445 ((['git', 'commit', '--amend', '-m', description],), | 474 ((['git', 'commit', '--amend', '-m', description],), |
| 446 ''), | 475 ''), |
| 447 ((['git', 'log', '--pretty=format:%s\n\n%b', 'master..'],), | 476 ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), |
| 448 description) | 477 description) |
| 449 ] | 478 ] |
| 450 calls += [ | 479 calls += [ |
| 451 ((['git', 'config', 'rietveld.cc'],), '') | 480 ((['git', 'config', 'rietveld.cc'],), '') |
| 452 ] | 481 ] |
| 453 receive_pack = '--receive-pack=git receive-pack ' | 482 receive_pack = '--receive-pack=git receive-pack ' |
| 454 receive_pack += '--cc=joe@example.com' # from watch list | 483 receive_pack += '--cc=joe@example.com' # from watch list |
| 455 if reviewers: | 484 if reviewers: |
| 456 receive_pack += ' ' | 485 receive_pack += ' ' |
| 457 receive_pack += ' '.join(['--reviewer=' + email for email in reviewers]) | 486 receive_pack += ' '.join(['--reviewer=' + email for email in reviewers]) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 ((['git', 'config', 'rietveld.viewvc-url'],), ''), | 579 ((['git', 'config', 'rietveld.viewvc-url'],), ''), |
| 551 (('ViewVC URL:',), ''), | 580 (('ViewVC URL:',), ''), |
| 552 # DownloadHooks(True) | 581 # DownloadHooks(True) |
| 553 ((commit_msg_path, os.X_OK,), True), | 582 ((commit_msg_path, os.X_OK,), True), |
| 554 ] | 583 ] |
| 555 git_cl.main(['config']) | 584 git_cl.main(['config']) |
| 556 | 585 |
| 557 | 586 |
| 558 if __name__ == '__main__': | 587 if __name__ == '__main__': |
| 559 unittest.main() | 588 unittest.main() |
| OLD | NEW |