Skip to content

Commit 7385278

Browse files
committed
bugfix: error when issues delete
1 parent 4076d13 commit 7385278

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

git-issues-blog.py

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,29 @@
9191
if pstr in dictionary:
9292
# get issue info
9393
issue_number = dictionary[pstr]
94-
issue = repo.get_issue(number=issue_number)
95-
issue_url = issue.html_url
96-
issue_title = issue.title
97-
98-
# content
99-
payload = {}
100-
payload['title'] = issue_title
101-
payload['body'] = issue_content
102-
103-
# github edit issue api
104-
header = {'Authorization': 'token %s' % GITHUB_TOKEN}
105-
106-
url = GITHUB_API + "/repos/" + GITHUB_REPO + "/issues/" + str(issue_number)
107-
r = requests.patch(url, headers=header, data=json.dumps(payload))
108-
if r.status_code == 200:
109-
print("issue update successful: %s" % issue_number)
110-
else:
111-
print("issue update failed: %s" % issue_number)
112-
exit(-1)
94+
try:
95+
issue = repo.get_issue(number=issue_number)
96+
97+
issue_url = issue.html_url
98+
issue_title = issue.title
99+
100+
# content
101+
payload = {}
102+
payload['title'] = issue_title
103+
payload['body'] = issue_content
104+
105+
# github edit issue api
106+
header = {'Authorization': 'token %s' % GITHUB_TOKEN}
107+
108+
url = GITHUB_API + "/repos/" + GITHUB_REPO + "/issues/" + str(issue_number)
109+
r = requests.patch(url, headers=header, data=json.dumps(payload))
110+
if r.status_code == 200:
111+
print("issue update successful: %s" % issue_number)
112+
else:
113+
print("issue update failed: %s" % issue_number)
114+
exit(-1)
115+
except GithubException as e:
116+
print('get issues: %s error, skip for next' % issue_number)
113117

114118
else:
115119
#creat issue
@@ -133,7 +137,7 @@
133137
repo.create_file(POST_INDEX_FILE, "add post index: _index", "{}", branch=GITHUB_BRANCH)
134138
#update POST_INDEX_FILE
135139
post_index_file = repo.get_contents(POST_INDEX_FILE,ref=GITHUB_BRANCH)
136-
post_index_content = json.dumps(dictionary)
140+
post_index_content = json.dumps(dictionary, ensure_ascii=False)
137141
post_index_msg = "rebuild posts index from: " + GITHUB_ACTION_NAME
138142
repo.update_file(post_index_file.path, post_index_msg, post_index_content, post_index_file.sha, branch=GITHUB_BRANCH)
139143

0 commit comments

Comments
 (0)