OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """This module uprevs a given package's ebuild to the next revision.""" | 7 """This module uprevs a given package's ebuild to the next revision.""" |
8 | 8 |
9 | 9 |
10 import fileinput | 10 import fileinput |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 for command in commands: | 103 for command in commands: |
104 command_usage += ' %s: %s\n' % (command, _COMMAND_DICTIONARY[command]) | 104 command_usage += ' %s: %s\n' % (command, _COMMAND_DICTIONARY[command]) |
105 commands_str = '|'.join(commands) | 105 commands_str = '|'.join(commands) |
106 print 'Usage: %s FLAGS [%s]\n\n%s\nFlags:%s' % (sys.argv[0], commands_str, | 106 print 'Usage: %s FLAGS [%s]\n\n%s\nFlags:%s' % (sys.argv[0], commands_str, |
107 command_usage, gflags.FLAGS) | 107 command_usage, gflags.FLAGS) |
108 if error_message: | 108 if error_message: |
109 generate_test_report.Die(error_message) | 109 generate_test_report.Die(error_message) |
110 else: | 110 else: |
111 sys.exit(1) | 111 sys.exit(1) |
112 | 112 |
113 def _BranchExists(name): | |
114 """Returns True is the branch exists""" | |
115 return _RunCommand('git branch').split().count(name) != 0 | |
116 | |
117 def _PushChange(): | 113 def _PushChange(): |
118 """Pushes changes to the git repository. | 114 """Pushes changes to the git repository. |
119 | 115 |
120 Pushes locals commits from calls to CommitChange to the remote git | 116 Pushes locals commits from calls to CommitChange to the remote git |
121 repository specified by os.pwd. | 117 repository specified by os.pwd. |
122 | 118 |
123 Raises: | 119 Raises: |
124 OSError: Error occurred while pushing. | 120 OSError: Error occurred while pushing. |
125 """ | 121 """ |
126 | 122 |
127 # TODO(sosa) - Add logic for buildbot to check whether other slaves have | 123 # TODO(sosa) - Add logic for buildbot to check whether other slaves have |
128 # completed and push this change only if they have. | 124 # completed and push this change only if they have. |
129 | 125 |
130 # Sanity check to make sure we're on a stabilizing branch before pushing. | 126 # Sanity check to make sure we're on a stabilizing branch before pushing. |
131 if not _CheckOnStabilizingBranch(): | 127 if not _CheckOnStabilizingBranch(): |
132 print 'Not on branch %s so no work found to push. Exiting' % \ | 128 print 'Not on branch %s so no work found to push. Exiting' % \ |
133 _STABLE_BRANCH_NAME | 129 _STABLE_BRANCH_NAME |
134 return | 130 return |
135 | 131 |
136 description = _RunCommand('git log --format=format:%s%n%n%b ' + | 132 description = _RunCommand('git log --format=format:%s%n%n%b ' + |
137 gflags.FLAGS.tracking_branch + '..') | 133 gflags.FLAGS.tracking_branch + '..') |
138 description = 'Marking set of ebuilds as stable\n\n%s' % description | 134 description = 'Marking set of ebuilds as stable\n\n%s' % description |
139 merge_branch_name = 'merge_branch' | 135 merge_branch_name = 'merge_branch' |
140 _RunCommand('git remote update') | 136 _RunCommand('git remote update') |
141 merge_branch = _GitBranch(merge_branch_name) | 137 merge_branch = _GitBranch(merge_branch_name) |
142 merge_branch.CreateBranch() | 138 merge_branch.CreateBranch() |
143 if not merge_branch.Exists(): | 139 if not merge_branch.Exists(): |
144 generate_test_report.Die('Unable to create merge branch.') | 140 generate_test_report.Die('Unable to create merge branch.') |
145 _RunCommand('git checkout -b %s %s' % ( | |
146 merge_branch_name, gflags.FLAGS.tracking_branch)) | |
147 _RunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) | 141 _RunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) |
148 _RunCommand('git commit -m "%s"' % description) | 142 _RunCommand('git commit -m "%s"' % description) |
149 # Ugh. There has got to be an easier way to push to a tracking branch | 143 # Ugh. There has got to be an easier way to push to a tracking branch |
150 _RunCommand('git config push.default tracking') | 144 _RunCommand('git config push.default tracking') |
151 _RunCommand('git push') | 145 _RunCommand('git push') |
152 | 146 |
153 | 147 |
154 def _RunCommand(command): | 148 def _RunCommand(command): |
155 """Runs a shell command and returns stdout back to caller.""" | 149 """Runs a shell command and returns stdout back to caller.""" |
156 _Print(' + %s' % command) | 150 _Print(' + %s' % command) |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 'and reset the git repo yourself.' % | 369 'and reset the git repo yourself.' % |
376 (package_list[:index], overlay_directory)) | 370 (package_list[:index], overlay_directory)) |
377 raise e | 371 raise e |
378 elif command == 'push': | 372 elif command == 'push': |
379 _PushChange() | 373 _PushChange() |
380 | 374 |
381 | 375 |
382 if __name__ == '__main__': | 376 if __name__ == '__main__': |
383 main(sys.argv) | 377 main(sys.argv) |
384 | 378 |
OLD | NEW |