|
1 | 1 | import random |
| 2 | +import time |
2 | 3 |
|
3 | 4 | from github import PullRequest |
4 | 5 |
|
5 | 6 | from pydocteur.utils.comment_body import get_comment_bodies |
6 | 7 |
|
7 | | - |
8 | 8 | END_OF_BODY = """ |
9 | 9 |
|
10 | 10 | --- |
@@ -46,7 +46,23 @@ def comment_pr(pr: PullRequest, state: str): |
46 | 46 | pr.create_issue_comment(body + END_OF_BODY.format(state=state)) |
47 | 47 |
|
48 | 48 |
|
49 | | -def merge_and_thanks(pr: PullRequest, state: str): |
50 | | - # TODO: Add label and message before doing anything to warn that it is being merged |
51 | | - # Don't forgot to add the state in the comment :p |
52 | | - pass |
| 49 | +def merge_and_thank_contributors(pr: PullRequest, state: str): |
| 50 | + warnings = get_comment_bodies("automerge_approved_testok") |
| 51 | + thanks = get_comment_bodies("automerge_approved_testok-done") |
| 52 | + |
| 53 | + print("MERGING: Sending warning") |
| 54 | + warning_body = random.choice(warnings) |
| 55 | + warning_body = replace_body_variables(pr, warning_body) |
| 56 | + pr.create_issue_comment(warning_body + END_OF_BODY.format(state=state)) |
| 57 | + |
| 58 | + print("MERGING: Sleeping 1s") |
| 59 | + time.sleep(1) |
| 60 | + |
| 61 | + print("MERGING: MERGING") |
| 62 | + # TODO: Custom commit message/title with nice infos and saying it's auto merged. |
| 63 | + pr.merge(merge_method="squash", commit_message="") |
| 64 | + |
| 65 | + print("MERGING: Sending thanks") |
| 66 | + thanks_body = random.choice(thanks) |
| 67 | + thanks_body = replace_body_variables(pr, thanks_body) |
| 68 | + pr.create_issue_comment(thanks_body + END_OF_BODY.format(state=state)) |
0 commit comments