The extensions that were in Toolshed's own repository, a folder each: brreg, dashboard-icons, databricks, docker, github, homebrew, norway, projects, scripts, secrets, wikipedia and yr. Toolshed installs them from here, in Settings → Extensions → From a repository, and the README says how
This commit is contained in:
44 files changed
+7978
-1
No files matched your search
@@ -0,0 +1,45 @@
|
||||
-- Says when the checks of a pull request of yours pass or fail, through gh. Toolshed runs it
|
||||
-- every minute, while it's turned on. What's been said is remembered, a commit's checks said once;
|
||||
-- the first time it runs, what's there already is noted.
|
||||
|
||||
local query = [[
|
||||
query {
|
||||
viewer {
|
||||
pullRequests(states: OPEN, first: 50) {
|
||||
nodes {
|
||||
number title url
|
||||
repository { nameWithOwner }
|
||||
commits(last: 1) { nodes { commit { oid statusCheckRollup { state } } } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}]]
|
||||
|
||||
-- The checks' states that are an end, as GitHub names them.
|
||||
local ended = { SUCCESS = "say.passed", FAILURE = "say.failed", ERROR = "say.failed" }
|
||||
|
||||
local seen = toolshed.memory()
|
||||
local first = seen == nil
|
||||
seen = seen or {}
|
||||
|
||||
-- A failure ends this run; Toolshed runs it again a while later.
|
||||
local data = toolshed.json.decode(toolshed.exec({ "gh", "api", "graphql", "-f", "query=" .. query })).data
|
||||
|
||||
local now = {}
|
||||
for _, pr in ipairs(data.viewer.pullRequests.nodes) do
|
||||
local commit = pr.commits.nodes[1] and pr.commits.nodes[1].commit
|
||||
local state = commit and commit.statusCheckRollup and commit.statusCheckRollup.state
|
||||
if state then
|
||||
local was = seen[pr.url]
|
||||
now[pr.url] = { oid = commit.oid, state = state }
|
||||
local changed = not was or was.oid ~= commit.oid or was.state ~= state
|
||||
if not first and changed and ended[state] then
|
||||
local said = { repo = pr.repository.nameWithOwner, number = pr.number, title = pr.title }
|
||||
local data = { repo = pr.repository.nameWithOwner, number = tostring(math.floor(pr.number)), url = pr.url .. "/checks" }
|
||||
toolshed.notify(toolshed.t(ended[state], said), { tool = "pr", stay = state ~= "SUCCESS", actions = {
|
||||
{ title = toolshed.t("action.web"), action = "web", data = data },
|
||||
} })
|
||||
end
|
||||
end
|
||||
end
|
||||
toolshed.remember(now)
|
||||
Reference in new issue
Block a user