| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium 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 import base64 | 5 import base64 |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 import urllib2 | 10 import urllib2 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 def in_flight_pull_requests(self): | 80 def in_flight_pull_requests(self): |
| 81 path = '/search/issues?q=repo:w3c/web-platform-tests%20is:open%20type:pr
%20label:{}'.format(EXPORT_LABEL) | 81 path = '/search/issues?q=repo:w3c/web-platform-tests%20is:open%20type:pr
%20label:{}'.format(EXPORT_LABEL) |
| 82 data, status_code = self.request(path, method='GET') | 82 data, status_code = self.request(path, method='GET') |
| 83 if status_code == 200: | 83 if status_code == 200: |
| 84 return data['items'] | 84 return data['items'] |
| 85 else: | 85 else: |
| 86 raise Exception('Non-200 status code (%s): %s' % (status_code, data)
) | 86 raise Exception('Non-200 status code (%s): %s' % (status_code, data)
) |
| 87 | 87 |
| 88 def merge_pull_request(self, pull_request_number): | 88 def merge_pull_request(self, pull_request_number): |
| 89 path = '/repos/w3c/web-platform-tests/pulls/%d/merge' % pull_request_num
ber | 89 path = '/repos/w3c/web-platform-tests/pulls/%d/merge' % pull_request_num
ber |
| 90 body = {} | 90 body = { |
| 91 'merge_method': 'rebase', |
| 92 } |
| 91 data, status_code = self.request(path, method='PUT', body=body) | 93 data, status_code = self.request(path, method='PUT', body=body) |
| 92 | 94 |
| 93 if status_code == 200: | 95 if status_code == 200: |
| 94 return data | 96 return data |
| 95 else: | 97 else: |
| 96 raise Exception('PR could not be merged: %d' % pull_request_number) | 98 raise Exception('PR could not be merged: %d' % pull_request_number) |
| 97 | 99 |
| 98 def delete_remote_branch(self, remote_branch_name): | 100 def delete_remote_branch(self, remote_branch_name): |
| 99 # TODO(jeffcarp): Unit test this method | 101 # TODO(jeffcarp): Unit test this method |
| 100 path = '/repos/w3c/web-platform-tests/git/refs/heads/%s' % remote_branch
_name | 102 path = '/repos/w3c/web-platform-tests/git/refs/heads/%s' % remote_branch
_name |
| 101 data, status_code = self.request(path, method='DELETE') | 103 data, status_code = self.request(path, method='DELETE') |
| 102 | 104 |
| 103 if status_code != 204: | 105 if status_code != 204: |
| 104 # TODO(jeffcarp): Raise more specific exception (create MergeError c
lass?) | 106 # TODO(jeffcarp): Raise more specific exception (create MergeError c
lass?) |
| 105 raise Exception('Received non-204 status code attempting to delete r
emote branch: {}'.format(status_code)) | 107 raise Exception('Received non-204 status code attempting to delete r
emote branch: {}'.format(status_code)) |
| 106 | 108 |
| 107 return data | 109 return data |
| OLD | NEW |