Repository navigation
Various hot fixes #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various hot fixes #135
Changes from all commits
f8d0582
388fe84
ae29fba
ea07ce0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| -- migrate:up | ||
|
|
||
| -- Deleting a connector cascades to its repositories; repo override policies blocked that. | ||
| -- A repo's override policy is meaningless without the repo, so delete it too. | ||
| ALTER TABLE auto_approve_policies DROP CONSTRAINT auto_approve_policies_repository_id_fkey; | ||
| ALTER TABLE auto_approve_policies ADD CONSTRAINT auto_approve_policies_repository_id_fkey | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info A new foreign key constraint has been added with Suggestions:
|
||
| FOREIGN KEY (repository_id) REFERENCES repositories(id) ON DELETE CASCADE; | ||
|
|
||
| -- migrate:down | ||
|
|
||
| ALTER TABLE auto_approve_policies DROP CONSTRAINT auto_approve_policies_repository_id_fkey; | ||
| ALTER TABLE auto_approve_policies ADD CONSTRAINT auto_approve_policies_repository_id_fkey | ||
| FOREIGN KEY (repository_id) REFERENCES repositories(id); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| -- migrate:up | ||
|
|
||
| -- Auto-approve is on by default: every org gets an org-level policy with the column defaults. | ||
| INSERT INTO auto_approve_policies (org_id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The default organization-level policy has been inserted. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Insert the default organization policy. Suggestions:
|
||
| SELECT o.id FROM orgs o | ||
| WHERE NOT EXISTS ( | ||
| SELECT 1 FROM auto_approve_policies p WHERE p.org_id = o.id AND p.repository_id IS NULL | ||
| ); | ||
|
|
||
| CREATE FUNCTION create_default_auto_approve_policy() RETURNS trigger | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info A function for the default policy has been created. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Create a trigger function for new organizations. Suggestions:
|
||
| LANGUAGE plpgsql | ||
| AS $$ | ||
| BEGIN | ||
| INSERT INTO auto_approve_policies (org_id) VALUES (NEW.id); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The default policy for new organizations has been inserted. Suggestions:
|
||
| RETURN NEW; | ||
| END; | ||
| $$; | ||
|
|
||
| CREATE TRIGGER orgs_default_auto_approve_policy | ||
| AFTER INSERT ON orgs | ||
| FOR EACH ROW EXECUTE FUNCTION create_default_auto_approve_policy(); | ||
|
|
||
| -- migrate:down | ||
|
|
||
| DROP TRIGGER IF EXISTS orgs_default_auto_approve_policy ON orgs; | ||
| DROP FUNCTION IF EXISTS create_default_auto_approve_policy(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,6 +113,20 @@ END | |
| $$; | ||
|
|
||
|
|
||
| -- | ||
| -- Name: create_default_auto_approve_policy(); Type: FUNCTION; Schema: public; Owner: - | ||
| -- | ||
|
|
||
| CREATE FUNCTION public.create_default_auto_approve_policy() RETURNS trigger | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info This is the function definition for the default policy. Suggestions:
|
||
| LANGUAGE plpgsql | ||
| AS $$ | ||
| BEGIN | ||
| INSERT INTO auto_approve_policies (org_id) VALUES (NEW.id); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Insert the default organization policy. Suggestions:
|
||
| RETURN NEW; | ||
| END; | ||
| $$; | ||
|
|
||
|
|
||
| -- | ||
| -- Name: license_seat_assignments_set_updated_at(); Type: FUNCTION; Schema: public; Owner: - | ||
| -- | ||
|
|
@@ -6120,6 +6134,13 @@ CREATE TRIGGER trg_org_billing_state_audit AFTER UPDATE ON public.org_billing_st | |
| CREATE TRIGGER trg_org_billing_state_updated_at BEFORE UPDATE ON public.org_billing_state FOR EACH ROW EXECUTE FUNCTION public.org_billing_state_set_updated_at(); | ||
|
|
||
|
|
||
| -- | ||
| -- Name: orgs orgs_default_auto_approve_policy; Type: TRIGGER; Schema: public; Owner: - | ||
| -- | ||
|
|
||
| CREATE TRIGGER orgs_default_auto_approve_policy AFTER INSERT ON public.orgs FOR EACH ROW EXECUTE FUNCTION public.create_default_auto_approve_policy(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info A trigger has been added to create the default policy for new organizations. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add a trigger for new organizations. Suggestions:
|
||
|
|
||
|
|
||
| -- | ||
| -- Name: plan_catalog trg_plan_catalog_updated_at; Type: TRIGGER; Schema: public; Owner: - | ||
| -- | ||
|
|
@@ -6216,7 +6237,7 @@ ALTER TABLE ONLY public.auto_approve_policies | |
| -- | ||
|
|
||
| ALTER TABLE ONLY public.auto_approve_policies | ||
| ADD CONSTRAINT auto_approve_policies_repository_id_fkey FOREIGN KEY (repository_id) REFERENCES public.repositories(id); | ||
| ADD CONSTRAINT auto_approve_policies_repository_id_fkey FOREIGN KEY (repository_id) REFERENCES public.repositories(id) ON DELETE CASCADE; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info This is a foreign key constraint with Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add the Suggestions:
|
||
|
|
||
|
|
||
| -- | ||
|
|
@@ -7258,4 +7279,6 @@ INSERT INTO public.schema_migrations (version) VALUES | |
| ('20260905090000'), | ||
| ('20261012090000'), | ||
| ('20261012100000'), | ||
| ('20261013090000'); | ||
| ('20261013090000'), | ||
| ('20261017090000'), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info New migration versions have been added. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add new migration versions. Suggestions:
|
||
| ('20261017100000'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add new migration versions. Suggestions:
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ require ( | |
| github.com/aws/aws-sdk-go-v2/service/s3 v1.102.2 | ||
| github.com/bwmarrin/discordgo v0.29.0 | ||
| github.com/d1vbyz3r0/typed v0.2.3 | ||
| github.com/getkin/kin-openapi v0.145.0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the Suggestions:
|
||
| github.com/getkin/kin-openapi v0.151.0 | ||
| github.com/go-co-op/gocron/v2 v2.22.0 | ||
| github.com/go-swiss/fonts v0.0.0-20230807175105-90067c2f5042 | ||
| github.com/golang-jwt/jwt/v5 v5.3.1 | ||
|
|
@@ -69,7 +69,7 @@ require ( | |
| google.golang.org/api v0.272.0 | ||
| ) | ||
|
|
||
| require github.com/cdipaolo/goml v0.0.0-20220715001353-00e0c845ae1c // indirect | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Ensure that the Suggestions:
|
||
| require github.com/cdipaolo/goml v0.0.0-20220715001353-00e0c845ae1c | ||
|
|
||
| require ( | ||
| cel.dev/expr v0.25.2 // indirect | ||
|
|
@@ -212,7 +212,7 @@ require ( | |
| github.com/sagikazarmark/locafero v0.7.0 // indirect | ||
| github.com/sagikazarmark/slog-shim v0.1.0 // indirect | ||
| github.com/sahilm/fuzzy v0.1.3 // indirect | ||
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the Suggestions:
|
||
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect | ||
| github.com/shopspring/decimal v1.4.0 // indirect | ||
| github.com/sirupsen/logrus v1.9.4 // indirect | ||
| github.com/sorairolake/lzip-go v0.3.8 // indirect | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,10 +75,6 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapp | |
| github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.55.0/go.mod h1:Mf6O40IAyB9zR/1J8nGDDPirZQQPbYJni8Yisy7NTMc= | ||
| github.com/HexmosTech/deidentify v1.0.0 h1:yC+CMoFdkyGNgSU4gEyB/AAJbJ3KLjqNuNe3Km/LCDA= | ||
| github.com/HexmosTech/deidentify v1.0.0/go.mod h1:1+fAOPPy8g/7KoF+OOY673j+3BxAs8xTzjlkNKgMWjU= | ||
| github.com/HexmosTech/git-lrc/blastradius v0.0.0-20261009104557-0cc6cb4e1a6c h1:ARY/iCSKMhvEWX3nG5OJVKQEsKc97l/rAsHUICmbozQ= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Remove the old Suggestions:
|
||
| github.com/HexmosTech/git-lrc/blastradius v0.0.0-20261009104557-0cc6cb4e1a6c/go.mod h1:uAX2wgGb22UPGzmXVs6b8rKRzZnEkfFlnhxiv/ewp9M= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Remove the old Suggestions:
|
||
| github.com/HexmosTech/git-lrc/blastradius v0.0.0-20261009151730-cb9fce8104d0 h1:4RTFP63IZ6cJJ+ibkAQ9m9sQbCa4Kxu0lkuiKw2++bQ= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Remove the old Suggestions:
|
||
| github.com/HexmosTech/git-lrc/blastradius v0.0.0-20261009151730-cb9fce8104d0/go.mod h1:uAX2wgGb22UPGzmXVs6b8rKRzZnEkfFlnhxiv/ewp9M= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Remove the old Suggestions:
|
||
| github.com/HexmosTech/git-lrc/blastradius v0.1.0 h1:fiykl9PI7plYe6cnKYT6uojVlzr8/EJb3sZ5Om+W4L8= | ||
| github.com/HexmosTech/git-lrc/blastradius v0.1.0/go.mod h1:uAX2wgGb22UPGzmXVs6b8rKRzZnEkfFlnhxiv/ewp9M= | ||
| github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= | ||
|
|
@@ -227,8 +223,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk | |
| github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= | ||
| github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= | ||
| github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= | ||
| github.com/getkin/kin-openapi v0.145.0 h1:htBX+Q7SevVaCUqymFegUKzH2WCbewl9tsmyn2FMGWY= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the Suggestions:
|
||
| github.com/getkin/kin-openapi v0.145.0/go.mod h1:3BH9M9XDe/y9M5DSvEocVYAYq1w0qrhJHjC/vZi0AaY= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the Suggestions:
|
||
| github.com/getkin/kin-openapi v0.151.0 h1:p8NIstL53h620DnlO9R4pR4QRkEzJ3jbw9flb4kc1hg= | ||
| github.com/getkin/kin-openapi v0.151.0/go.mod h1:1+BHDzstro+P5CKtPy1X4PfofnFgmRe6uvMy9+r9fKY= | ||
| github.com/gitleaks/go-gitdiff v0.9.1 h1:ni6z6/3i9ODT685OLCTf+s/ERlWUNWQF4x1pvoNICw0= | ||
| github.com/gitleaks/go-gitdiff v0.9.1/go.mod h1:pKz0X4YzCKZs30BL+weqBIG7mx0jl4tF1uXV9ZyNvrA= | ||
| github.com/go-co-op/gocron/v2 v2.22.0 h1:uEuH2F7k7VoESb1BYSaffuuV+T0kkpzsC0aXk7/z79I= | ||
|
|
@@ -510,8 +506,8 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g | |
| github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= | ||
| github.com/sahilm/fuzzy v0.1.3 h1:juByESSS32nVD81vr6tHmKmA/8zde7gE+x5CLxrzXPU= | ||
| github.com/sahilm/fuzzy v0.1.3/go.mod h1:au6//VbVSqu6DFrkL2CfjlJ5iURpNCPeE+1GwY3XsT8= | ||
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the Suggestions:
|
||
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the Suggestions:
|
||
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28= | ||
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= | ||
| github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= | ||
| github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= | ||
| github.com/shrsv/AgentLaws v0.2.1 h1:00pN3dEhsFFtz+qrcqBwVy8ieLzaivHbpyyuAk3+Lsk= | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,15 +98,7 @@ func (s *Server) createReview(c echo.Context) error { | |
| return c.JSON(http.StatusInternalServerError, ErrorResponse{Error: err.Error()}) | ||
| } | ||
| s.enrichMetadata(ctx) | ||
| if req.FromPRLink { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The inline SQL has been removed and replaced by a helper function. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Extract the policy check marking logic into a new method. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add a check to ensure Suggestions:
|
||
| // Marks the review so the worker runs the approval policy check once it completes. | ||
| if _, err := s.db.Exec( | ||
| `UPDATE reviews SET metadata = COALESCE(metadata, '{}'::jsonb) || '{"pr_link_policy": true}'::jsonb WHERE id = $1 AND org_id = $2`, | ||
| ctx.review.ID, orgID, | ||
| ); err != nil { | ||
| log.Printf("[WARN] createReview: failed to mark review %d for policy check: %v", ctx.review.ID, err) | ||
| } | ||
| } | ||
| s.markForPolicyCheck(ctx.review.ID, orgID) | ||
| s.trackActivity(ctx) | ||
| if err := s.launchBackgroundProcessing(ctx); err != nil { | ||
| log.Printf("[ERROR] createReview: Failed to queue manual review: %v", err) | ||
|
|
@@ -152,3 +144,15 @@ func (s *Server) getPullRequestOrg(c echo.Context) error { | |
| } | ||
| return JSONWithEnvelope(c, http.StatusOK, map[string]interface{}{"org_id": orgID}) | ||
| } | ||
|
|
||
| // markForPolicyCheck flags a manual PR review so the worker runs the approval policy check once it completes. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Document the new helper method. Suggestions:
|
||
| // Reviews not linked to a known PR are left alone. | ||
| func (s *Server) markForPolicyCheck(reviewID, orgID int64) { | ||
| if _, err := s.db.Exec( | ||
| `UPDATE reviews SET metadata = COALESCE(metadata, '{}'::jsonb) || '{"pr_link_policy": true}'::jsonb | ||
| WHERE id = $1 AND org_id = $2 AND pull_request_id IS NOT NULL`, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info A condition has been added to only update reviews that are linked to a pull request. Suggestions:
|
||
| reviewID, orgID, | ||
| ); err != nil { | ||
| log.Printf("[WARN] failed to mark review %d for policy check: %v", reviewID, err) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,6 +138,7 @@ func (s *Server) TriggerReviewV2(c echo.Context) error { | |
|
|
||
| // Phase 4: Enrich metadata (fetch MR details, update DB) | ||
| s.enrichMetadata(ctx) | ||
| s.markForPolicyCheck(ctx.review.ID, ctx.orgID) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info A call has been added to mark the review for a policy check. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Call the Suggestions:
|
||
|
|
||
| // Phase 5: Track activity (log the trigger event) | ||
| s.trackActivity(ctx) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,8 @@ Any authenticated org member. | |
|
|
||
| - Search/filter/sort PRs by provider, repo, state, etc. | ||
| - Trigger a review directly for a specific pull request | ||
| (`triggerReviewForPullRequest`). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The description has been updated to include information about the policy check. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Clarify that the policy check runs upon completion. Suggestions:
|
||
| (`triggerReviewForPullRequest`). It opens the new review's page right away, | ||
| and the review runs the auto-approve policy check when it finishes. | ||
|
|
||
| ## Related pages | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,9 +5,9 @@ | |
|
|
||
| ## Purpose | ||
|
|
||
| Form to manually trigger a code review (as opposed to it firing from a git | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the purpose description. Suggestions:
|
||
| webhook or the `lrc` CLI hook). Lets the user pick a connected AI provider | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The description for manual reviews has been updated. Suggestions:
|
||
| and target repository/PR, then submits the review job. | ||
| Start a code review of one pull/merge request right away (as opposed to it | ||
| firing from a git webhook or the `lrc` CLI hook). Below the form, an "Other | ||
| ways to review" section lists the other ways reviews can start. | ||
|
|
||
| ## Who can access it | ||
|
|
||
|
|
@@ -18,15 +18,25 @@ self-hosted license limits. | |
|
|
||
| ## Key actions | ||
|
|
||
| - Select an AI connector and repository/PR to review. | ||
| - Submit the review (`triggerReview` API call); redirects to the new | ||
| review's detail page on success. | ||
| - **Back** (top left) returns to the previous page. | ||
| - Type a repository name, PR title or author to see matching open PRs. Click | ||
| one, or use ↑/↓ and Enter, to start its review. | ||
| - Or paste a PR/MR URL and click **Start review**. Either way the new review's | ||
| page opens right away, and for a PR LiveReview already synced the org's | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The policy check process for pull request reviews has been clarified. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Provide details on the policy check for pull request reviews. Suggestions:
|
||
| auto-approve policy runs when the review finishes. | ||
| - Hover a provider chip (GitHub, GitLab, Bitbucket, Gitea, Azure DevOps) to see | ||
| its URL format. | ||
| - **Other ways to review** cards: On the PR (assign the bot as reviewer, | ||
| @mention it, or use the PR description's Start a review link), Pre-commit CLI, | ||
| IDE / MCP, CI/CD & API (CI rulesets), Chatbot (opens Livi with a review prompt), | ||
| and Scheduled reviews. | ||
| - If blocked by quota, see an upgrade prompt (`UpgradePromptModal`) instead. | ||
|
|
||
| ## Related pages | ||
|
|
||
| - [Reviews list](reviews-list.md) | ||
| - [Review Detail](review-detail.md) | ||
| - [Explore → Merge Requests](../explore/merge-requests.md) | ||
| - [Create Review via CLI](create-review-cli.md) | ||
| - [Create Review via MCP](create-review-mcp.md) | ||
| - [AI Providers](../ai/ai-providers.md) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,19 @@ | |
| ## Purpose | ||
|
|
||
| When a new pull/merge request is opened on GitHub, GitLab, Bitbucket, Gitea, or Azure DevOps in a repo with the | ||
| LiveReview webhook installed, LiveReview adds a section with two links to the end of its description: | ||
| LiveReview webhook installed, LiveReview adds a section to the end of its description: | ||
|
|
||
| - **Start a review** → this page. It starts a LiveReview review of that PR and | ||
| opens the review's detail page. | ||
| - **Review history** → the [Reviews list](reviews-list.md) filtered to that | ||
| PR (`/reviews?pull_request_id=<id>`). | ||
| - A line under the auto-approval decisions (or under the two links before any | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Information regarding policy customization links has been added. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add links for policy customization. Suggestions:
|
||
| decision): "Customize risk-based approval policy for **this repository** or | ||
| **your organization**". The repository link opens the repo's settings page, | ||
| Auto Approve section (`/explore/repositories/<repo id>/settings#auto-approve`); | ||
| the organization link opens [Settings → Auto Approve Policies](../settings/auto-approve.md) | ||
| (`/settings#auto-approve`). Both pages are for org owners and admins, and | ||
| open in the user's current org. | ||
|
|
||
| `:id` is LiveReview's internal pull request id, not the GitHub/GitLab PR number. | ||
| The section is added once per PR, only when it's opened (not for PRs that | ||
|
|
@@ -49,8 +56,9 @@ aren't members of that org see "pull request wasn't found". | |
| - Azure DevOps: a comment thread, then the bot votes Approved or | ||
| "Waiting for author". | ||
| - The decisions table shows the last 10 policy-checked reviews. | ||
| - Reviews started any other way (reviewer assignment, @mentions, Explore) don't | ||
| run the policy check. | ||
| - Reviews started by hand for a known PR also run the policy check and get the | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info It has been clarified which review triggers the policy check. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Clarify which pull request reviews trigger the policy check. Suggestions:
|
||
| Auto Approve tab: pasting the PR URL on New Review, or Start review in the | ||
| Explore PR table. Reviewer assignment and @mention reviews don't. | ||
|
|
||
| ## Related pages | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -278,7 +278,7 @@ const ( | |
| legacySectionEnd = "<!-- livereview:end -->" | ||
| ) | ||
|
|
||
| // postLinksComment adds the "Start a review / Review history" links to the end of a new PR/MR's description. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The comment has been updated to reflect the new links. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the description for the comment function. Suggestions:
|
||
| // postLinksComment adds the LiveReview links (review, history, repo/org policy) to the end of a new PR/MR's description. | ||
| // The links_comment_posted_at claim stops duplicate webhook deliveries from adding it twice. | ||
| func (w *PRStateSyncWorker) postLinksComment(ctx context.Context, repositoryID, pullRequestID int64, number int) error { | ||
| host, err := w.webhookStore.GetWebhookPublicEndpoint(ctx) | ||
|
|
@@ -299,7 +299,7 @@ func (w *PRStateSyncWorker) postLinksComment(ctx context.Context, repositoryID, | |
|
|
||
| info, err := loadRepositoryConnectorInfo(w.db, repositoryID) | ||
| if err == nil { | ||
| err = writePRSection(ctx, info, number, buildPRLinksSection(host, pullRequestID, "")) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Pass the Suggestions:
|
||
| err = writePRSection(ctx, info, number, buildPRLinksSection(host, pullRequestID, repositoryID, "")) | ||
| } | ||
| if err != nil { | ||
| // Release the claim so River's retry can add it. | ||
|
|
@@ -312,7 +312,7 @@ func (w *PRStateSyncWorker) postLinksComment(ctx context.Context, repositoryID, | |
| } | ||
|
|
||
| // buildPRLinksSection renders the LiveReview section; history is the review history table, or "". | ||
| func buildPRLinksSection(host string, pullRequestID int64, history string) string { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add the Suggestions:
|
||
| func buildPRLinksSection(host string, pullRequestID, repositoryID int64, history string) string { | ||
| host = strings.TrimSuffix(host, "/") | ||
| return fmt.Sprintf(`%s | ||
|
|
||
|
|
@@ -322,8 +322,10 @@ func buildPRLinksSection(host string, pullRequestID int64, history string) strin | |
| - ▶️ **[Start a review](%s/#/pr/%d/review)**: reviews all changes in this PR against its target branch | ||
| - 📜 **[Review history](%s/#/reviews?pull_request_id=%d)**: all past reviews of this PR | ||
|
|
||
| %s%s | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Links for policy customization have been added. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Add repository and organization policy links. Suggestions:
|
||
| `, prSectionStart, host, pullRequestID, host, pullRequestID, history, prSectionEnd) | ||
| %s⚙️ Customize risk-based approval policy for [this repository](%s/#/explore/repositories/%d/settings#auto-approve) or [your organization](%s/#/settings#auto-approve). | ||
|
|
||
| %s | ||
| `, prSectionStart, host, pullRequestID, host, pullRequestID, history, host, repositoryID, host, prSectionEnd) | ||
| } | ||
|
|
||
| // refreshPRSection rewrites the LiveReview section with one history row per policy-checked review of this PR. | ||
|
|
@@ -369,7 +371,7 @@ func refreshPRSection(ctx context.Context, db *sql.DB, info *repositoryConnector | |
| return err | ||
| } | ||
| b.WriteString("\n") | ||
| return writePRSection(ctx, info, number, buildPRLinksSection(host, pullRequestID, b.String())) | ||
| return writePRSection(ctx, info, number, buildPRLinksSection(host, pullRequestID, info.RepositoryID, b.String())) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Pass the Suggestions:
|
||
| } | ||
|
|
||
| // decisionReason is the readable "why" for one decision row: each failing stage's reason, or that all passed. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,13 +38,23 @@ func seedOrg(t *testing.T, db *sql.DB, name string) int64 { | |
| // already inserted a row for this org by the time the test ends; its FK | ||
| // has no cascade, so it must be cleared first or the org delete leaks. | ||
| _, _ = db.Exec(`DELETE FROM dashboard_cache WHERE org_id = $1`, orgID) | ||
| _, _ = db.Exec(`DELETE FROM auto_approve_policies WHERE org_id = $1`, orgID) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The default policy for the organization has been deleted. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Delete the default organization policy row. Suggestions:
|
||
| _, _ = db.Exec(`DELETE FROM orgs WHERE id = $1`, orgID) | ||
| }) | ||
| return orgID | ||
| } | ||
|
|
||
| func insertPolicy(t *testing.T, db *sql.DB, orgID int64, repoID *int64, mode string, minLevel int) int64 { | ||
| var id int64 | ||
| if repoID == nil { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The default organization-level policy has been updated. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Update the default organization policy if Suggestions:
|
||
| // Every new org already gets a default org-level row from a trigger; reuse it. | ||
| if err := db.QueryRow(` | ||
| UPDATE auto_approve_policies SET mode = $2, min_author_level = $3 | ||
| WHERE org_id = $1 AND repository_id IS NULL RETURNING id`, orgID, mode, minLevel).Scan(&id); err != nil { | ||
| t.Fatalf("update default policy: %v", err) | ||
| } | ||
| return id | ||
| } | ||
| if err := db.QueryRow(` | ||
| INSERT INTO auto_approve_policies (org_id, repository_id, mode, min_author_level) | ||
| VALUES ($1, $2, $3, $4) RETURNING id`, orgID, repoID, mode, minLevel).Scan(&id); err != nil { | ||
|
|
@@ -62,6 +72,10 @@ func insertPolicy(t *testing.T, db *sql.DB, orgID int64, repoID *int64, mode str | |
| func TestResolvePolicyNoneConfigured(t *testing.T) { | ||
| db := testDB(t) | ||
| orgID := seedOrg(t, db, "policy-resolve-none") | ||
| // Drop the default row the org-insert trigger created. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The default policy row has been deleted. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Delete the default organization policy row. Suggestions:
|
||
| if _, err := db.Exec(`DELETE FROM auto_approve_policies WHERE org_id = $1`, orgID); err != nil { | ||
| t.Fatalf("delete default policy: %v", err) | ||
| } | ||
|
|
||
| _, found, err := ResolvePolicy(context.Background(), db, orgID, 0) | ||
| if err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ const AzureDevOpsConnector: React.FC = () => { | |
| return ( | ||
| <div className="space-y-4"> | ||
| <div className="flex items-center"> | ||
| <Button variant="ghost" icon={<Icons.Add />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The button icon has been changed to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The icon has been changed from 'Add' to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Apply a negative margin for alignment purposes. Suggestions:
|
||
| <Button variant="ghost" icon={<Icons.Back />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm -ml-4"> | ||
| Back to providers | ||
| </Button> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ const BitbucketConnector: React.FC = () => { | |
| return ( | ||
| <div className="space-y-4"> | ||
| <div className="flex items-center"> | ||
| <Button variant="ghost" icon={<Icons.Add />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The button icon has been changed to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The icon has been changed from 'Add' to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Apply a negative margin for alignment purposes. Suggestions:
|
||
| <Button variant="ghost" icon={<Icons.Back />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm -ml-4"> | ||
| Back to providers | ||
| </Button> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ const GitHubConnector: React.FC = () => { | |
| return ( | ||
| <div className="space-y-4"> | ||
| <div className="flex items-center"> | ||
| <Button variant="ghost" icon={<Icons.Add />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The button icon has been changed to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The icon has been changed from 'Add' to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Apply a negative margin for alignment purposes. Suggestions:
|
||
| <Button variant="ghost" icon={<Icons.Back />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm -ml-4"> | ||
| Back to providers | ||
| </Button> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ const GitLabComConnector: React.FC = () => { | |
| return ( | ||
| <div className="space-y-4"> | ||
| <div className="flex items-center"> | ||
| <Button variant="ghost" icon={<Icons.Add />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The button icon has been changed to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info The icon has been changed from 'Add' to 'Back'. Suggestions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: info Apply a negative margin for alignment purposes. Suggestions:
|
||
| <Button variant="ghost" icon={<Icons.Back />} onClick={() => navigate('/git')} iconPosition="left" className="text-sm -ml-4"> | ||
| Back to providers | ||
| </Button> | ||
| </div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity: info
The existing foreign key constraint has been removed.
Suggestions: