lex-github 0.3.4 → 0.3.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/legion/extensions/github/runners/contents.rb +7 -0
- data/lib/legion/extensions/github/runners/pull_requests.rb +64 -4
- data/lib/legion/extensions/github/runners/repositories.rb +9 -0
- data/lib/legion/extensions/github/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3d7a7f7bb14416475d247ced95d050133ca186ba90b27def22a2eb650f9f281
|
|
4
|
+
data.tar.gz: 18ebc886fae52273743d338ea6d8c392427c11ce247221abd34bcf4ecc431109
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 392c217ec7e3cbfe66f594ee7d61d226ddaafa70d641034e7ef4da8cd3f6e043e6413b056ebe2c550306e47c3674c0d21fe9bfa2d726ae6dbb09d11d6e2e8912
|
|
7
|
+
data.tar.gz: '09c432cd5d0f1b50c9f5dbc375d2301b56b6a21a0fc15880471c9b11c3c717858bda02ff4c88212eb652e41127f438d00ec0b08c5de2b2c951913bde8a6e88e5'
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.3.5] - 2026-04-13
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `mark_pr_ready`: GraphQL `markPullRequestAsReady` mutation to remove draft status from a PR (REST API has no endpoint for this); includes private `graphql_connection` helper
|
|
9
|
+
- `get_tree`: fetch recursive repo file tree via Git Trees API (`GET /repos/{owner}/{repo}/git/trees/{sha}`)
|
|
10
|
+
- `get_file_content`: fetch a single file's content via Contents API with optional `ref` param
|
|
11
|
+
- `list_all_pull_request_files`: paginated variant that collects all pages (100/page) until exhausted; original `list_pull_request_files` preserved for backward compat
|
|
12
|
+
- `list_pull_request_review_comments`: fetch inline code review comments (`GET /pulls/{n}/comments`), distinct from issue comments
|
|
13
|
+
- `list_pull_request_commits`: simplified variant (per_page: 100, no cache) for fleet validator stale-diff guard
|
|
14
|
+
|
|
5
15
|
## [0.3.4] - 2026-04-06
|
|
6
16
|
|
|
7
17
|
### Added
|
|
@@ -11,6 +11,13 @@ module Legion
|
|
|
11
11
|
include Legion::Extensions::Github::Helpers::Client
|
|
12
12
|
include Legion::Extensions::Github::Helpers::Cache
|
|
13
13
|
|
|
14
|
+
def get_file_content(owner:, repo:, path:, ref: nil, **)
|
|
15
|
+
params = ref ? { ref: ref } : {}
|
|
16
|
+
{ result: connection(owner: owner, repo: repo, **).get(
|
|
17
|
+
"/repos/#{owner}/#{repo}/contents/#{path}", params
|
|
18
|
+
).body }
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
def commit_files(owner:, repo:, branch:, files:, message:, **)
|
|
15
22
|
conn = connection(owner: owner, repo: repo, **)
|
|
16
23
|
|
|
@@ -45,11 +45,36 @@ module Legion
|
|
|
45
45
|
{ result: response.body }
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
def list_pull_request_commits(owner:, repo:, pull_number:, per_page:
|
|
48
|
+
def list_pull_request_commits(owner:, repo:, pull_number:, per_page: 100, **)
|
|
49
|
+
{ result: connection(owner: owner, repo: repo, **).get(
|
|
50
|
+
"/repos/#{owner}/#{repo}/pulls/#{pull_number}/commits", { per_page: per_page }
|
|
51
|
+
).body }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def list_all_pull_request_files(owner:, repo:, pull_number:, **)
|
|
55
|
+
all_files = []
|
|
56
|
+
page = 1
|
|
57
|
+
per_page = 100
|
|
58
|
+
|
|
59
|
+
loop do
|
|
60
|
+
batch = connection(owner: owner, repo: repo, **).get(
|
|
61
|
+
"/repos/#{owner}/#{repo}/pulls/#{pull_number}/files",
|
|
62
|
+
{ per_page: per_page, page: page }
|
|
63
|
+
).body
|
|
64
|
+
all_files.concat(batch)
|
|
65
|
+
break if batch.size < per_page
|
|
66
|
+
|
|
67
|
+
page += 1
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
{ result: all_files }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def list_pull_request_review_comments(owner:, repo:, pull_number:, per_page: 30, page: 1, **)
|
|
49
74
|
params = { per_page: per_page, page: page }
|
|
50
|
-
{ result:
|
|
51
|
-
|
|
52
|
-
|
|
75
|
+
{ result: connection(owner: owner, repo: repo, **).get(
|
|
76
|
+
"/repos/#{owner}/#{repo}/pulls/#{pull_number}/comments", params
|
|
77
|
+
).body }
|
|
53
78
|
end
|
|
54
79
|
|
|
55
80
|
def list_pull_request_files(owner:, repo:, pull_number:, per_page: 30, page: 1, **)
|
|
@@ -72,8 +97,43 @@ module Legion
|
|
|
72
97
|
{ result: response.body }
|
|
73
98
|
end
|
|
74
99
|
|
|
100
|
+
def mark_pr_ready(owner:, repo:, pull_number:, **)
|
|
101
|
+
pr_data = get_pull_request(owner: owner, repo: repo, pull_number: pull_number)
|
|
102
|
+
node_id = pr_data.dig(:result, 'node_id') || pr_data.dig(:result, :node_id)
|
|
103
|
+
return { success: false, reason: :no_node_id } unless node_id
|
|
104
|
+
|
|
105
|
+
query = <<~GRAPHQL
|
|
106
|
+
mutation {
|
|
107
|
+
markPullRequestAsReady(input: { pullRequestId: "#{node_id}" }) {
|
|
108
|
+
pullRequest { id isDraft }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
GRAPHQL
|
|
112
|
+
|
|
113
|
+
conn = graphql_connection(owner: owner, repo: repo)
|
|
114
|
+
response = conn.post('/graphql', { query: query })
|
|
115
|
+
errors = response.body['errors']
|
|
116
|
+
return { success: false, reason: :graphql_error, errors: errors } if errors&.any?
|
|
117
|
+
|
|
118
|
+
{ success: true, result: response.body.dig('data', 'markPullRequestAsReady', 'pullRequest') }
|
|
119
|
+
end
|
|
120
|
+
|
|
75
121
|
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
76
122
|
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
123
|
+
|
|
124
|
+
private
|
|
125
|
+
|
|
126
|
+
def graphql_connection(owner: nil, repo: nil, **)
|
|
127
|
+
resolved = respond_to?(:resolve_credential, true) ? resolve_credential(owner: owner, repo: repo) : nil
|
|
128
|
+
resolved_token = resolved&.dig(:token)
|
|
129
|
+
|
|
130
|
+
Faraday.new(url: 'https://api.github.com') do |conn|
|
|
131
|
+
conn.request :json
|
|
132
|
+
conn.response :json, content_type: /\bjson$/
|
|
133
|
+
conn.headers['Accept'] = 'application/vnd.github+json'
|
|
134
|
+
conn.headers['Authorization'] = "Bearer #{resolved_token}" if resolved_token
|
|
135
|
+
end
|
|
136
|
+
end
|
|
77
137
|
end
|
|
78
138
|
end
|
|
79
139
|
end
|
|
@@ -53,6 +53,15 @@ module Legion
|
|
|
53
53
|
end }
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
+
def get_tree(owner:, repo:, tree_sha:, recursive: true, **)
|
|
57
|
+
params = recursive ? { recursive: true } : {}
|
|
58
|
+
{ result: cached_get("github:repo:#{owner}/#{repo}:tree:#{tree_sha}:#{recursive}") do
|
|
59
|
+
connection(owner: owner, repo: repo, **).get(
|
|
60
|
+
"/repos/#{owner}/#{repo}/git/trees/#{tree_sha}", params
|
|
61
|
+
).body
|
|
62
|
+
end }
|
|
63
|
+
end
|
|
64
|
+
|
|
56
65
|
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
|
|
57
66
|
Legion::Extensions::Helpers.const_defined?(:Lex, false)
|
|
58
67
|
end
|