diff --git a/connectors/github.py b/connectors/github.py index 5f078f2..48435bc 100644 --- a/connectors/github.py +++ b/connectors/github.py @@ -84,7 +84,7 @@ def create_issue(self, title, msg, assignee, labels=[], repo=None): return True except GithubException as e: GitHubConnector.log_exception(e.data) - if assignee is None: + if assignee is GithubObject.NotSet: return False else: # try without assignee diff --git a/controllers/issues.py b/controllers/issues.py index 6e121bf..274c925 100644 --- a/controllers/issues.py +++ b/controllers/issues.py @@ -68,6 +68,10 @@ def copy_issues(self, mapping_file, fromrepo, torepo, offset): mapping_dict = parsers.csvparser.get_rows_as_dict(mapping_file) if mapping_file is not None else {} REF_TEMPLATE = '\n\n[original: {}#{}]' + if torepo.count('{}') > 1: + logging.error('torepo contains more than 1 replacement field!') + sys.exit(1) + if not offset: offset = 0 @@ -79,13 +83,17 @@ def copy_issues(self, mapping_file, fromrepo, torepo, offset): if from_mapping: from_mapping = from_mapping.group(1) - print(from_mapping) - to_mapping = mapping_dict.get(from_mapping, from_mapping) + to_mapping = mapping_dict.get(from_mapping, []) + + try: + actl_to_repo = torepo.format(to_mapping[0]) + except IndexError: + actl_to_repo = torepo.format('') - is_transferred = self.ghc.create_issue(new_title, new_body, None, to_mapping, torepo) + is_transferred = self.ghc.create_issue(new_title, new_body, None, to_mapping, actl_to_repo) if not is_transferred: - logging.error('Unable to create issue with idx: %s', user) + logging.error('[%d][#%d][%s -> %s] Unable to copy', idx, issue.number, fromrepo, actl_to_repo) def blast_issues(self, csv_file, title, msg_file, start_from): """ diff --git a/example/issues/copy/mapping.csv b/example/issues/copy/mapping.csv new file mode 100644 index 0000000..3a6ee9d --- /dev/null +++ b/example/issues/copy/mapping.csv @@ -0,0 +1,4 @@ +origin1,tag1,tag2,tag3 +origin2,tag1,tag2,tag3 +origin3,tag1,tag2,tag3 +(and so on...) \ No newline at end of file