Created
September 17, 2018 20:57
-
-
Save blairconrad/a7e2ef6c966175f78955c57b4d585d31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- .\crucible-orig.py 2018-08-16 13:38:18.101556600 -0400 | |
+++ .\crucible.py 2018-09-17 16:40:00.600443200 -0400 | |
@@ -651,20 +651,22 @@ | |
else: | |
print('No reviewers added, review will be left in Draft state') | |
Console.success('Created review %(id)s (state: %(state)s) - %(url)s/cru/%(id)s' | |
% ({'id': review_id, 'state': review_state,'url':self.configuration.url})) | |
def add_patch_data(self, patch, request_dict={}): | |
request_dict['patch'] = patch | |
if self.configuration.repository: | |
request_dict['anchor'] = {'anchorRepository' : self.configuration.repository} | |
+ if self.configuration.path: | |
+ request_dict['anchor']['anchorPath'] = self.configuration.path | |
return request_dict | |
def get_iterable_patchgroups(self, review_id, repository): | |
patch_groups = self._request('/rest-service/reviews-v1/%s/patch' % review_id)['patchGroup'] | |
matching_repo = lambda patch_group: 'anchor' in patch_group['patches'][0] and \ | |
patch_group['patches'][0]['anchor'].get('anchorRepository') == repository | |
return filter(matching_repo, patch_groups) | |
def add_to_review(self, patch, review): | |
"""Adds the patch and reviewers to the given review""" | |
@@ -935,28 +938,31 @@ | |
check_output([self.configuration.executables[self.executable()], 'help']) | |
def load_paths(self): | |
info_output = check_output([self.configuration.executables[self.executable()], 'info']).splitlines() | |
if info_output: | |
for line in info_output: | |
if line.startswith('URL:'): | |
line_split = line.split() | |
if (len(line_split)) > 1: | |
self.paths.append(line_split[1].strip()) | |
- break | |
+ if line.startswith('Repository Root:'): | |
+ line_split = line.split() | |
+ if (len(line_split)) > 1: | |
+ self.repository = line_split[-1].strip() | |
+ | |
def matches_repository(self, repository_data): | |
if not repository_data['type'] == 'svn': | |
return False | |
- remote_url = (repository_data['url'].rstrip('/') + '/' + repository_data['path']).rstrip('/') | |
- logging.debug('Matching remote url %s', remote_url) | |
- return self.paths[0].startswith(remote_url) | |
+ logging.debug('repository = %s', self.repository) | |
+ return self.repository.split('/')[-1] == repository_data['name'] | |
class CvsSource(PatchSource): | |
"""Gets a patch from a CVS repository""" | |
def is_active(self): | |
try: | |
cmd = [self.configuration.executables[self.executable()], 'status'] | |
check_output(cmd) | |
return True | |
except (OSError, CalledProcessError): | |
@@ -1131,20 +1137,21 @@ | |
if args.patch: | |
print(patch) | |
sys.exit(0) | |
# create or update the review | |
if not configuration.repository and not configuration.no_anchor: | |
detected_repository = rest.find_repository(source) | |
if detected_repository: | |
configuration.repository = detected_repository | |
+ configuration.path = source.paths[0] | |
print('Detected Crucible repository %s. Use --repository or --noanchor options to override' % configuration.repository) | |
else: | |
print('No matching FishEye repository detected') | |
configuration.choose_anchor(rest.get_repositories()) | |
configuration.last_project = rest.get_last_project() | |
configuration.fill_interactively(get_id=True) | |
review = rest.get_review(configuration.id) | |
if review: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment