def in_github(self, existing_issues={}): if len(existing_issues) == 0: repo = ghissues.gh_repo() for i in repo.get_issues(state='open'): existing_issues[i.title] = i.number for i in repo.get_issues(state='closed'): existing_issues[i.title] = i.number print len(existing_issues), "existing issues" return existing_issues.get(self.github.title, False)
def trac_id_to_github_number(tracid, issuemap={}): if len(issuemap) == 0: repo = ghissues.gh_repo() for i in repo.get_issues(state='open'): if 'Trac #' in i.title: tracid = int(i.title.split('#')[-1][:-1]) issuemap[tracid] = i.number for i in repo.get_issues(state='closed'): if 'Trac #' in i.title: tracid = int(i.title.split('#')[-1][:-1]) issuemap[tracid] = i.number print len(issuemap), "existing issues" return issuemap.get(tracid, False)
def push(self): repo = ghissues.gh_repo() github_issue = repo.create_issue(title=self.github.title, body=self.github.body, milestone=self.github.milestone, labels=self.github.labels) try: for comment in self.github.comments: github_issue.create_comment(comment) except: print("!!! Error in comments for ticket %s" % self.trac.id) finally: if self.github.state == "closed": github_issue.edit(state='closed') pass
def repush_comments(self): repo = ghissues.gh_repo() existing_id = self.in_github() print "Replacing comments in", existing_id github_issue = repo.get_issue(self.in_github()) for comment in github_issue.get_comments(): comment.delete() try: for comment in self.github.comments: github_issue.create_comment(comment) except: print("!!! Error in comments for ticket %s" % self.trac.id) finally: if self.github.state == "closed": github_issue.edit(state='closed') pass
def repush_body(self): repo = ghissues.gh_repo() existing_id = self.in_github() print "Replacing body in", existing_id github_issue = repo.get_issue(self.in_github()) github_issue.edit(body=self.github.body)