Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
40 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

The sidebar asks billing whether it is on, not for the account, so no page waits on the card processor1-- Checks are workflows, and the default branch's protection chooses which
2-- of them must pass: for every pull request, a person's or an agent's.
3-- Commands written on an issue are no longer run.
4
5-- The checks that must pass before a pull request merges, by name (a
6-- workflow's name, such as "CI", or another status's context): JSON array.
7ALTER TABLE repo_settings ADD COLUMN required_checks TEXT NOT NULL DEFAULT '[]';
8
9-- Until now every workflow reported on a pull request's head held its merge.
10-- Repositories whose pull requests had workflows keep exactly that, made
11-- visible: the workflows reported for pull_request events in the last 30
12-- days become the default branch's required checks. Only where none are
13-- set yet, so running this again changes nothing.
14INSERT INTO repo_settings (repo_id, updated_by, updated_at, required_checks)
15SELECT s.repo_id, 'g1t', strftime('%Y-%m-%dT%H:%M:%fZ', 'now'),
16 json_group_array(DISTINCT substr(s.context, 1, length(s.context) - length(' / pull_request')))
17FROM commit_statuses s
18JOIN pulls p ON p.repo_id = s.repo_id AND p.head_commit = s.sha
19WHERE s.context LIKE '% / pull_request'
20 AND s.updated_at >= strftime('%Y-%m-%dT%H:%M:%fZ', 'now', '-30 days')
21GROUP BY s.repo_id
22ON CONFLICT (repo_id) DO UPDATE SET required_checks = excluded.required_checks
23WHERE repo_settings.required_checks = '[]';
24
25-- An issue's commands become words its agent and reviewers read: added to
26-- its body under "Definition of done", once. The column is kept, as it
27-- was, for the record; nothing reads it any more.
28UPDATE issues
29SET body = CASE WHEN trim(body) = '' THEN '' ELSE rtrim(body, ' ' || char(10) || char(13)) || char(10) || char(10) END
30 || '## Definition of done' || char(10) || char(10)
31 || (SELECT group_concat('- `' || replace(value, '`', '''') || '` passes.', char(10))
32 FROM json_each(issues.checks) WHERE trim(value) != '')
33WHERE checks != '[]'
34 AND instr(body, '## Definition of done') = 0
35 AND EXISTS (SELECT 1 FROM json_each(issues.checks) WHERE trim(value) != '');
36
37-- What earlier runs of those commands said about open pull requests no
38-- longer decides anything: their workflows do.
39UPDATE pulls SET check_status = NULL, check_run_id = NULL
40WHERE status IN ('draft', 'open') AND check_status IS NOT NULL;

This file's history is long; its oldest lines are credited to the oldest commit read.