OLD | NEW |
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # Documentation on PRESUBMIT.py can be found at: | 5 # Documentation on PRESUBMIT.py can be found at: |
6 # http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts | 6 # http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts |
7 | 7 |
8 EXCLUDE_PROJECT_CHECKS_DIRS = [ '.' ] | 8 EXCLUDE_PROJECT_CHECKS_DIRS = [ '.' ] |
9 | 9 |
10 import subprocess | 10 import subprocess |
11 def CheckGitBranch(): | 11 def CheckGitBranch(): |
12 p = subprocess.Popen("git branch -vv", shell=True, | 12 p = subprocess.Popen("git branch -vv", shell=True, |
13 stdout=subprocess.PIPE) | 13 stdout=subprocess.PIPE) |
14 output, _ = p.communicate() | 14 output, _ = p.communicate() |
15 | 15 |
16 lines = output.split('\n') | 16 lines = output.split('\n') |
17 for line in lines: | 17 for line in lines: |
18 # output format for checked-out branch should be | 18 # output format for checked-out branch should be |
19 # * branchname hash [TrackedBranchName ... | 19 # * branchname hash [TrackedBranchName ... |
20 toks = line.split() | 20 toks = line.split() |
21 if '*' not in toks[0]: | 21 if '*' not in toks[0]: |
22 continue | 22 continue |
23 if not 'origin/master' in toks[3]: | 23 if not 'origin/master' in toks[3]: |
24 warning = 'Warning: your current branch:\n' + line | 24 warning = 'Warning: your current branch:\n' + line |
25 warning += '\nis not tracking origin/master. git cl push may silently ' | 25 warning += '\nis not tracking origin/master. git cl push may silently ' |
26 warning += 'fail to push your change. To fix this, do\n' | 26 warning += 'fail to push your change. To fix this, do\n' |
27 warning += 'git branch --set-upstream '+ toks[1] + ' origin/master' | 27 warning += 'git branch -u origin/master' |
28 return warning | 28 return warning |
29 return None | 29 return None |
30 print 'Warning: presubmit check could not determine local git branch' | 30 print 'Warning: presubmit check could not determine local git branch' |
31 return None | 31 return None |
32 | 32 |
33 def _CommonChecks(input_api, output_api): | 33 def _CommonChecks(input_api, output_api): |
34 """Checks for both upload and commit.""" | 34 """Checks for both upload and commit.""" |
35 results = [] | 35 results = [] |
36 results.extend(input_api.canned_checks.PanProjectChecks( | 36 results.extend(input_api.canned_checks.PanProjectChecks( |
37 input_api, output_api, project_name='Native Client', | 37 input_api, output_api, project_name='Native Client', |
(...skipping 19 matching lines...) Expand all Loading... |
57 Args: | 57 Args: |
58 input_api: the limited set of input modules allowed in presubmit. | 58 input_api: the limited set of input modules allowed in presubmit. |
59 output_api: the limited set of output modules allowed in presubmit. | 59 output_api: the limited set of output modules allowed in presubmit. |
60 """ | 60 """ |
61 report = [] | 61 report = [] |
62 report.extend(CheckChangeOnUpload(input_api, output_api)) | 62 report.extend(CheckChangeOnUpload(input_api, output_api)) |
63 return report | 63 return report |
64 | 64 |
65 def GetPreferredTrySlaves(project, change): | 65 def GetPreferredTrySlaves(project, change): |
66 return [] | 66 return [] |
OLD | NEW |