github-overlord 0.6.3__tar.gz → 0.6.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {github_overlord-0.6.3 → github_overlord-0.6.5}/PKG-INFO +2 -2
- {github_overlord-0.6.3 → github_overlord-0.6.5}/github_overlord/__init__.py +26 -7
- {github_overlord-0.6.3 → github_overlord-0.6.5}/github_overlord/stale_commenter.py +26 -5
- {github_overlord-0.6.3 → github_overlord-0.6.5}/pyproject.toml +2 -2
- {github_overlord-0.6.3 → github_overlord-0.6.5}/README.md +0 -0
- {github_overlord-0.6.3 → github_overlord-0.6.5}/github_overlord/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: github-overlord
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.5
|
|
4
4
|
Summary: Automatically merge Dependabot PRs in public repositories
|
|
5
5
|
Home-page: https://github.com/iloveitaly/github-overlord
|
|
6
6
|
Keywords: github,dependabot,automation
|
|
@@ -13,7 +13,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
13
13
|
Requires-Dist: apscheduler (>=3.10.4,<4.0.0)
|
|
14
14
|
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
15
15
|
Requires-Dist: funcy-pipe (>=0.11.0,<0.12.0)
|
|
16
|
-
Requires-Dist: openai (>=1.35.
|
|
16
|
+
Requires-Dist: openai (>=1.35.3,<2.0.0)
|
|
17
17
|
Requires-Dist: pygithub (>=2.3.0,<3.0.0)
|
|
18
18
|
Requires-Dist: python-decouple-typed (>=3.11.0,<4.0.0)
|
|
19
19
|
Requires-Dist: structlog (>=24.2.0,<25.0.0)
|
|
@@ -10,7 +10,11 @@ from github.GithubObject import NotSet
|
|
|
10
10
|
from github.Notification import Notification
|
|
11
11
|
from github.PullRequest import PullRequest
|
|
12
12
|
|
|
13
|
-
from github_overlord.stale_commenter import
|
|
13
|
+
from github_overlord.stale_commenter import (
|
|
14
|
+
check_for_stale_comments,
|
|
15
|
+
inspect_repo_for_stale_prs,
|
|
16
|
+
is_stale_comment,
|
|
17
|
+
)
|
|
14
18
|
from github_overlord.utils import log
|
|
15
19
|
|
|
16
20
|
AUTOMATIC_MERGE_MESSAGE = "Automatically merged with GitHub overlord"
|
|
@@ -156,11 +160,14 @@ def cli():
|
|
|
156
160
|
pass
|
|
157
161
|
|
|
158
162
|
|
|
159
|
-
def extract_repo_reference_from_github_url(url: str):
|
|
163
|
+
def extract_repo_reference_from_github_url(url: str | None):
|
|
160
164
|
"""
|
|
161
165
|
Extract the owner and repo from a GitHub URL
|
|
162
166
|
"""
|
|
163
167
|
|
|
168
|
+
if url is None:
|
|
169
|
+
return None
|
|
170
|
+
|
|
164
171
|
# convert 'https://github.com/iloveitaly/todoist-digest/pulls' to 'iloveitaly/todoist-digest'
|
|
165
172
|
if "github.com" in url:
|
|
166
173
|
match = re.search(r"github\.com/([^/]+)/([^/]+)", url)
|
|
@@ -186,6 +193,7 @@ def dependabot(token, dry_run, repo):
|
|
|
186
193
|
"""
|
|
187
194
|
|
|
188
195
|
repo = extract_repo_reference_from_github_url(repo)
|
|
196
|
+
|
|
189
197
|
main(token, dry_run, repo)
|
|
190
198
|
|
|
191
199
|
|
|
@@ -199,14 +207,25 @@ def dependabot(token, dry_run, repo):
|
|
|
199
207
|
@click.option("--dry-run", is_flag=True, help="Run script without merging PRs")
|
|
200
208
|
@click.option("--repo", help="Only process a single repository")
|
|
201
209
|
def keep_alive_prs(token, dry_run, repo):
|
|
202
|
-
|
|
210
|
+
assert token, "GitHub token is required"
|
|
211
|
+
# TODO should assert on openai setup
|
|
203
212
|
|
|
204
213
|
github = Github(token)
|
|
205
|
-
|
|
214
|
+
user = github.get_user()
|
|
215
|
+
login = user.login
|
|
216
|
+
|
|
217
|
+
repo = extract_repo_reference_from_github_url(repo)
|
|
218
|
+
|
|
219
|
+
if repo:
|
|
220
|
+
inspect_repo_for_stale_prs(dry_run, login, github.get_repo(repo))
|
|
221
|
+
return
|
|
222
|
+
|
|
223
|
+
# TODO this isn't perfect because you may be a contributor :/
|
|
224
|
+
user.get_repos(type="public") | fp.filter(
|
|
225
|
+
lambda repo: repo.owner.login != login
|
|
226
|
+
) | fp.map(fp.partial(inspect_repo_for_stale_prs, dry_run, login)) | fp.to_list()
|
|
206
227
|
|
|
207
|
-
|
|
208
|
-
lambda pr: pr.user.login == login
|
|
209
|
-
) | fp.map(check_for_stale_comments) | fp.to_list()
|
|
228
|
+
log.info("stale PR check complete")
|
|
210
229
|
|
|
211
230
|
|
|
212
231
|
def notifications(token, dry_run):
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import json
|
|
2
2
|
|
|
3
|
+
import funcy_pipe as fp
|
|
4
|
+
from github import Github
|
|
3
5
|
from github.IssueComment import IssueComment
|
|
4
6
|
from github.PullRequest import PullRequest
|
|
7
|
+
from github.Repository import Repository
|
|
5
8
|
from openai import OpenAI
|
|
6
9
|
|
|
7
10
|
from github_overlord.utils import log
|
|
8
11
|
|
|
9
12
|
|
|
10
|
-
def
|
|
13
|
+
def inspect_repo_for_stale_prs(dry_run: bool, login: str, repo: Repository):
|
|
14
|
+
log.debug("inspecting repo for stale PRs", repo=repo.full_name)
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
repo.get_pulls(state="open")
|
|
18
|
+
| fp.filter(lambda pr: pr.user.login == login)
|
|
19
|
+
| fp.map(fp.partial(check_for_stale_comments, dry_run))
|
|
20
|
+
| fp.to_list()
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def check_for_stale_comments(dry_run: bool, pr: PullRequest):
|
|
11
25
|
"""
|
|
12
26
|
Look at PRs which you have written:
|
|
13
27
|
|
|
@@ -42,7 +56,9 @@ def check_for_stale_comments(pr: PullRequest):
|
|
|
42
56
|
log.info(
|
|
43
57
|
"comment indicates stale state, commenting", url=pr.html_url, comment=comment
|
|
44
58
|
)
|
|
45
|
-
|
|
59
|
+
|
|
60
|
+
if not dry_run:
|
|
61
|
+
pr.create_issue_comment(comment)
|
|
46
62
|
|
|
47
63
|
|
|
48
64
|
def is_stale_comment(comment: IssueComment):
|
|
@@ -56,8 +72,8 @@ A GitHub pull request comment will be included with the author name. Determine i
|
|
|
56
72
|
request will be closed, respond with a JSON object like:
|
|
57
73
|
|
|
58
74
|
{
|
|
59
|
-
"stale": "yes",
|
|
60
|
-
"comment": "Friendly reminder on this pull request! Let me know what else may need to be done here."
|
|
75
|
+
"stale": "yes",
|
|
76
|
+
"comment": "Friendly reminder on this pull request! Let me know what else may need to be done here."
|
|
61
77
|
}
|
|
62
78
|
|
|
63
79
|
Adjust the comment wording slightly.
|
|
@@ -65,8 +81,13 @@ Adjust the comment wording slightly.
|
|
|
65
81
|
If the comment does not indicate that the pull request will be closed, respond with:
|
|
66
82
|
|
|
67
83
|
{
|
|
68
|
-
"stale": "no",
|
|
84
|
+
"stale": "no",
|
|
69
85
|
}
|
|
86
|
+
|
|
87
|
+
Do not:
|
|
88
|
+
|
|
89
|
+
* Ask for an update. This sound demanding.
|
|
90
|
+
* Mention that the pull request will be closed.
|
|
70
91
|
"""
|
|
71
92
|
comment_markdown = """
|
|
72
93
|
Author: {comment.user.login}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "github-overlord"
|
|
3
|
-
version = "0.6.
|
|
3
|
+
version = "0.6.5"
|
|
4
4
|
description = "Automatically merge Dependabot PRs in public repositories"
|
|
5
5
|
authors = ["Michael Bianco <mike@mikebian.co>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -15,7 +15,7 @@ python-decouple-typed = "^3.11.0"
|
|
|
15
15
|
funcy-pipe = "^0.11.0"
|
|
16
16
|
structlog = "^24.2.0"
|
|
17
17
|
apscheduler = "^3.10.4"
|
|
18
|
-
openai = "^1.35.
|
|
18
|
+
openai = "^1.35.3"
|
|
19
19
|
|
|
20
20
|
[tool.poetry.scripts]
|
|
21
21
|
github-overlord = "github_overlord:cli"
|
|
File without changes
|
|
File without changes
|