本文整理汇总了Python中git.Git.getIssues方法的典型用法代码示例。如果您正苦于以下问题:Python Git.getIssues方法的具体用法?Python Git.getIssues怎么用?Python Git.getIssues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Git
的用法示例。
在下文中一共展示了Git.getIssues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: link
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import getIssues [as 别名]
def link():
config_yaml = open("config.yaml", "r")
config = yaml.load(config_yaml)
config_yaml.close()
trello_board = config["trello_board"]
git = Git(config["git_username"], config["git_email"], config["git_password"])
trello = Trello(config["trello_key"], config["trello_token"])
#first get all issues from the github repo
shared_topics = {}
issues = git.getIssues("Brewmaster")
issue_titles = []
for issue in issues:
issue_titles.append(issue["title"])
#get all cards from trello board
card_names = []
cards = trello.getCards(trello_board)
for card in cards:
card_names.append(card["name"])
for label in card["labels"]:
if GIT == label["name"]:
if not card["name"] in issue_titles:
label_list = []
for label in card["labels"]:
if not label["name"] == GIT:
label_list.append(label["name"])
title = card["name"]
body = card["desc"]
response = git.raiseIssue("Brewmaster", title, body,
labels=label_list)
comments = trello.getCardComments(card["id"])
for comment in comments:
body = comment["data"]["text"]
git.comment("Brewmaster", response["number"],
body)
else:
shared_topics[str(card["name"])] = [card]
lists = trello.getLists(config["trello_board"])
labels = trello.getLabels(config["trello_board"])
for issue in issues:
if not issue["title"] in card_names:
#add issue as a trello card
#label it
name = issue["title"]
desc = issue["body"]
label_list = []
for label in issue["labels"]:
label_list.append(label["name"])
label_ids = []
for label in labels:
if label["name"].lower() in label_list:
label_ids.append(label["id"])
if label["name"] == GIT:
label_ids.append(label["id"])
list_name = None
if issue["state"] == "open":
if issue["comments"] > 0:
list_name = "Doing"
else:
list_name = "To Do"
else:
list_name = "Done"
list_id = None
for list in lists:
if list["name"] == list_name:
list_id = list["id"]
response = trello.addCard(name, desc, list_id, label_ids)
#add all comments as trello card comments
comments = git.getIssueComments("Brewmaster", str(issue["number"]))
for comment in comments:
body = comment["body"]
trello.comment(response["id"], body)
else:
shared_topics[issue["title"]].append(issue)
""" next check if each issue/card in the dictionary are synced
if not, then adjust the older version to match the most recently
updated version
Check update times:
card["dateLastActivity"], issue["updated_at"]
Formatted:
2015-09-27T00:12:32.556Z 2015-09-26T21:52:01Z """
for key in shared_topics.keys():
#both on Zulu time
issue = shared_topics[key][1]
card = shared_topics[key][0]
issue_time = issue["updated_at"]
card_time = card["dateLastActivity"]
issue_time = datetime.strptime(issue_time,"%Y-%m-%dT%H:%M:%SZ")
card_time = datetime.strptime(card_time,"%Y-%m-%dT%H:%M:%S.%fZ")
if issue_time > card_time:
sync(git, trello, issue, card, "issue", config)
elif card_time > issue_time:
sync(git, trello, issue, card, "card", config)