feat(*): initialize new Snix infrastructure
Co-Authored-By: edef <edef@edef.eu> Co-Authored-by: Ryan Lahfa <raito@lix.systems> Change-Id: Ica1cda177a236814de900f50a8a61d288f58f519
This commit is contained in:
parent
067eff3427
commit
a52ea3675c
124 changed files with 27723 additions and 1631 deletions
28
third_party/lix_forgejo/0001-lix-Make-a-Code-Review-Gerrit-tab.patch
vendored
Normal file
28
third_party/lix_forgejo/0001-lix-Make-a-Code-Review-Gerrit-tab.patch
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
From 0edb45d9dc9a2688c8b66a21df2a555f864fb81c Mon Sep 17 00:00:00 2001
|
||||
From: Jade Lovelace <software@lfcode.ca>
|
||||
Date: Thu, 16 May 2024 18:15:54 -0700
|
||||
Subject: [PATCH 1/2] lix: Make a Code Review (Gerrit) tab
|
||||
|
||||
---
|
||||
templates/repo/header.tmpl | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl
|
||||
index 21017415c1..c5a36b2203 100644
|
||||
--- a/templates/repo/header.tmpl
|
||||
+++ b/templates/repo/header.tmpl
|
||||
@@ -99,6 +99,11 @@
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
+ {{if and (eq .Repository.Name "snix") (eq .Repository.OwnerName "snix")}}
|
||||
+ <a class="item" href="https://cl.snix.dev/q/project:snix">
|
||||
+ {{svg "octicon-code-review"}} Code Review (Gerrit)
|
||||
+ </a>
|
||||
+ {{end}}
|
||||
{{if .Permission.CanRead $.UnitTypeExternalTracker}}
|
||||
<a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
|
||||
{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues"}}
|
||||
--
|
||||
2.45.1
|
||||
|
||||
113
third_party/lix_forgejo/0002-lix-link-gerrit-cl-and-change-ids.patch
vendored
Normal file
113
third_party/lix_forgejo/0002-lix-link-gerrit-cl-and-change-ids.patch
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
From c560d6e110377fb6f42e841a0bd35f80c0f2eb29 Mon Sep 17 00:00:00 2001
|
||||
From: Jade Lovelace <software@lfcode.ca>
|
||||
Date: Thu, 16 May 2024 19:56:25 -0700
|
||||
Subject: [PATCH 2/2] lix: link gerrit cl/ and change-ids
|
||||
|
||||
This code is a bit dubious but you know, golang
|
||||
|
||||
Co-authored-by: Ryan Lahfa <raito@lix.systems>
|
||||
---
|
||||
modules/markup/html.go | 59 ++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 59 insertions(+)
|
||||
|
||||
diff --git a/modules/markup/html.go b/modules/markup/html.go
|
||||
index 2e65827bf7..2d474077a5 100644
|
||||
--- a/modules/markup/html.go
|
||||
+++ b/modules/markup/html.go
|
||||
@@ -50,6 +50,20 @@ var (
|
||||
// so that abbreviated hash links can be used as well. This matches git and GitHub usability.
|
||||
hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,:](\s|$))`)
|
||||
|
||||
+ // Gerrit change ID pattern
|
||||
+ changeIdPattern = GerritPattern{
|
||||
+ urlMatch: 1,
|
||||
+ displayMatch: 1,
|
||||
+ pattern: regexp.MustCompile(`(?:\s|^|\(|\[)(I[0-9a-f]{8,40})(?:\s|$|\)|\]|[.,](\s|$))`),
|
||||
+ }
|
||||
+
|
||||
+ // Gerrit cl/ pattern
|
||||
+ clSlashPattern = GerritPattern{
|
||||
+ urlMatch: 2,
|
||||
+ displayMatch: 1,
|
||||
+ pattern: regexp.MustCompile(`(?:^|[\s\]\[(){},.;:!?])(cl/([0-9]{0,6}))(?:$|[\s\]\[(){},.;:!?])`),
|
||||
+ }
|
||||
+
|
||||
// shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax
|
||||
shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`)
|
||||
|
||||
@@ -77,6 +91,14 @@ var (
|
||||
InlineCodeBlockRegex = regexp.MustCompile("`[^`]+`")
|
||||
)
|
||||
|
||||
+type GerritPattern struct {
|
||||
+ // The match group to put in the URL
|
||||
+ urlMatch int
|
||||
+ // The match group to render as the link
|
||||
+ displayMatch int
|
||||
+ pattern *regexp.Regexp
|
||||
+}
|
||||
+
|
||||
// CSS class for action keywords (e.g. "closes: #1")
|
||||
const keywordClass = "issue-keyword"
|
||||
|
||||
@@ -152,6 +174,7 @@ var defaultProcessors = []processor{
|
||||
issueIndexPatternProcessor,
|
||||
commitCrossReferencePatternProcessor,
|
||||
hashCurrentPatternProcessor,
|
||||
+ gerritCLPatternProcessor,
|
||||
emailAddressProcessor,
|
||||
emojiProcessor,
|
||||
emojiShortCodeProcessor,
|
||||
@@ -179,6 +202,7 @@ var commitMessageProcessors = []processor{
|
||||
issueIndexPatternProcessor,
|
||||
commitCrossReferencePatternProcessor,
|
||||
hashCurrentPatternProcessor,
|
||||
+ gerritCLPatternProcessor,
|
||||
emailAddressProcessor,
|
||||
emojiProcessor,
|
||||
emojiShortCodeProcessor,
|
||||
@@ -788,6 +812,41 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) {
|
||||
}
|
||||
}
|
||||
|
||||
+func gerritCLPatternProcessor(ctx *RenderContext, node *html.Node) {
|
||||
+ if ctx.Metas == nil || node == nil {
|
||||
+ return
|
||||
+ }
|
||||
+
|
||||
+ pats := []*GerritPattern{
|
||||
+ &changeIdPattern,
|
||||
+ &clSlashPattern,
|
||||
+ }
|
||||
+
|
||||
+ next := node.NextSibling
|
||||
+ for node != nil && node != next {
|
||||
+ for _, pat := range pats {
|
||||
+ m := pat.pattern.FindStringSubmatchIndex(node.Data)
|
||||
+ if m == nil {
|
||||
+ continue
|
||||
+ }
|
||||
+
|
||||
+ linkPart := node.Data[m[pat.urlMatch*2]:m[pat.urlMatch*2+1]]
|
||||
+ linkNamePart := node.Data[m[pat.displayMatch*2]:m[pat.displayMatch*2+1]]
|
||||
+ link := util.URLJoin("https://cl.snix.dev/q", linkPart)
|
||||
+ replaceContent(node, m[pat.displayMatch*2], m[pat.displayMatch*2+1], createCodeLink(link, linkNamePart, ""))
|
||||
+ }
|
||||
+
|
||||
+ // FIXME: I don't understand how any of this stuff was supposed to work to
|
||||
+ // begin with, since it seems like it returns if it doesn't just match in
|
||||
+ // the first node???!
|
||||
+ if node.NextSibling == nil {
|
||||
+ return
|
||||
+ }
|
||||
+
|
||||
+ node = node.NextSibling.NextSibling
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
func fullIssuePatternProcessor(ctx *RenderContext, node *html.Node) {
|
||||
if ctx.Metas == nil {
|
||||
return
|
||||
--
|
||||
2.47.0
|
||||
|
||||
79
third_party/lix_forgejo/api-dont-notify.patch
vendored
Normal file
79
third_party/lix_forgejo/api-dont-notify.patch
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
From 616ea9925fb7a28f1594694665ca89462bcbd461 Mon Sep 17 00:00:00 2001
|
||||
From: Jade Lovelace <software@lfcode.ca>
|
||||
Date: Tue, 19 Mar 2024 18:42:13 -0700
|
||||
Subject: [PATCH] Add a dont_notify option to the issue create api
|
||||
|
||||
yolo
|
||||
---
|
||||
modules/structs/issue.go | 1 +
|
||||
routers/api/v1/repo/issue.go | 2 +-
|
||||
routers/web/repo/issue.go | 2 +-
|
||||
services/issue/issue.go | 6 +++++-
|
||||
4 files changed, 8 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/modules/structs/issue.go b/modules/structs/issue.go
|
||||
index e2b49e94c5..09d239cdb7 100644
|
||||
--- a/modules/structs/issue.go
|
||||
+++ b/modules/structs/issue.go
|
||||
@@ -97,6 +97,7 @@ type CreateIssueOption struct {
|
||||
// list of label ids
|
||||
Labels []int64 `json:"labels"`
|
||||
Closed bool `json:"closed"`
|
||||
+ DontNotify bool `json:"dont_notify"`
|
||||
}
|
||||
|
||||
// EditIssueOption options for editing an issue
|
||||
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go
|
||||
index 0d304dd66d..d9431ef201 100644
|
||||
--- a/routers/api/v1/repo/issue.go
|
||||
+++ b/routers/api/v1/repo/issue.go
|
||||
@@ -708,7 +708,7 @@ func CreateIssue(ctx *context.APIContext) {
|
||||
form.Labels = make([]int64, 0)
|
||||
}
|
||||
|
||||
- if err := issue_service.NewIssue(ctx, ctx.Repo.Repository, issue, form.Labels, nil, assigneeIDs); err != nil {
|
||||
+ if err := issue_service.NewIssue(ctx, ctx.Repo.Repository, issue, form.Labels, nil, assigneeIDs, !form.DontNotify); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedByUser) {
|
||||
ctx.Error(http.StatusForbidden, "BlockedByUser", err)
|
||||
return
|
||||
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
|
||||
index afa6160d42..dbc500819e 100644
|
||||
--- a/routers/web/repo/issue.go
|
||||
+++ b/routers/web/repo/issue.go
|
||||
@@ -1249,7 +1249,7 @@ func NewIssuePost(ctx *context.Context) {
|
||||
Ref: form.Ref,
|
||||
}
|
||||
|
||||
- if err := issue_service.NewIssue(ctx, repo, issue, labelIDs, attachments, assigneeIDs); err != nil {
|
||||
+ if err := issue_service.NewIssue(ctx, repo, issue, labelIDs, attachments, assigneeIDs, true); err != nil {
|
||||
if errors.Is(err, user_model.ErrBlockedByUser) {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.issues.blocked_by_user"), tplIssueNew, form)
|
||||
return
|
||||
diff --git a/services/issue/issue.go b/services/issue/issue.go
|
||||
index 5e726176d0..cdb2f69828 100644
|
||||
--- a/services/issue/issue.go
|
||||
+++ b/services/issue/issue.go
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
)
|
||||
|
||||
// NewIssue creates new issue with labels for repository.
|
||||
-func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *issues_model.Issue, labelIDs []int64, uuids []string, assigneeIDs []int64) error {
|
||||
+func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *issues_model.Issue, labelIDs []int64, uuids []string, assigneeIDs []int64, notify bool) error {
|
||||
// Check if the user is not blocked by the repo's owner.
|
||||
if user_model.IsBlocked(ctx, repo.OwnerID, issue.PosterID) {
|
||||
return user_model.ErrBlockedByUser
|
||||
@@ -45,7 +45,11 @@ func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *issues_mo
|
||||
return err
|
||||
}
|
||||
|
||||
+ if !notify {
|
||||
+ return nil
|
||||
+ }
|
||||
notify_service.NewIssue(ctx, issue, mentions)
|
||||
+
|
||||
if len(issue.Labels) > 0 {
|
||||
notify_service.IssueChangeLabels(ctx, issue.Poster, issue, issue.Labels, nil)
|
||||
}
|
||||
--
|
||||
2.44.0
|
||||
|
||||
18
third_party/lix_forgejo/default.nix
vendored
Normal file
18
third_party/lix_forgejo/default.nix
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Patches that the Lix core team developed for git.lix.systems
|
||||
# Re-applied for git.snix.dev
|
||||
{ ... }: {
|
||||
patches = {
|
||||
# Show a link to upstream for a nixos/nix repository.
|
||||
upstream_link = ./upstream-link.patch;
|
||||
# Make it possible not to be notified upon issue creation.
|
||||
# Minimize noise.
|
||||
api_dont_notify = ./api-dont-notify.patch;
|
||||
# Sign in redirection to the OAuth 2 handler.
|
||||
signin_redirect = ./signin-redirect.patch;
|
||||
# Series to make Forgejo more Gerrit compatible.
|
||||
forgejo_is_now_gerrit_native = ./0001-lix-Make-a-Code-Review-Gerrit-tab.patch;
|
||||
# Modified for our Gerrit instance.
|
||||
forgejo_knows_about_gerrit = ./0002-lix-link-gerrit-cl-and-change-ids.patch;
|
||||
};
|
||||
custom_emojis = ./emojis.txt;
|
||||
}
|
||||
1
third_party/lix_forgejo/emojis.txt
vendored
Normal file
1
third_party/lix_forgejo/emojis.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
30
third_party/lix_forgejo/signin-redirect.patch
vendored
Normal file
30
third_party/lix_forgejo/signin-redirect.patch
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
From efba969f2ea6505417546e5f628066e3f10817d5 Mon Sep 17 00:00:00 2001
|
||||
From: Puck Meerburg <puck@puckipedia.com>
|
||||
Date: Wed, 8 May 2024 19:28:34 +0000
|
||||
Subject: [PATCH] Auto-redirect to oauth2 if a provider is available.
|
||||
|
||||
---
|
||||
routers/web/auth/auth.go | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go
|
||||
index 50fd760d80..c6cb5c9075 100644
|
||||
--- a/routers/web/auth/auth.go
|
||||
+++ b/routers/web/auth/auth.go
|
||||
@@ -186,6 +186,13 @@ func SignIn(ctx *context.Context) {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
return
|
||||
}
|
||||
+
|
||||
+ if len(oauth2Providers) > 0 {
|
||||
+ provider := oauth2Providers[0]
|
||||
+ ctx.Redirect(setting.AppSubURL + "/user/oauth2/" + provider.DisplayName())
|
||||
+ return
|
||||
+ }
|
||||
+
|
||||
ctx.Data["OAuth2Providers"] = oauth2Providers
|
||||
ctx.Data["Title"] = ctx.Tr("sign_in")
|
||||
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login"
|
||||
--
|
||||
2.44.0
|
||||
|
||||
14
third_party/lix_forgejo/upstream-link.patch
vendored
Normal file
14
third_party/lix_forgejo/upstream-link.patch
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl
|
||||
index c1dd265..9a573ce 100644
|
||||
--- a/templates/repo/issue/view_title.tmpl
|
||||
+++ b/templates/repo/issue/view_title.tmpl
|
||||
@@ -16,6 +16,9 @@
|
||||
{{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}}
|
||||
<button id="edit-title" class="ui small basic button edit-button not-in-edit{{if .Issue.IsPull}} gt-mr-0{{end}}">{{.locale.Tr "repo.issues.edit"}}</button>
|
||||
{{end}}
|
||||
+ {{if and (eq .Repository.Name "nix") (eq .Repository.OwnerName "NixOS")}}
|
||||
+ <a role="button" class="ui small basic button" href="https://github.com/NixOS/nix/issues/{{.Issue.Index}}">{{svg "octicon-mark-github"}} Open upstream</a>
|
||||
+ {{end}}
|
||||
{{if not .Issue.IsPull}}
|
||||
<a role="button" class="ui small green button new-issue-button gt-mr-0" href="{{.RepoLink}}/issues/new{{if .NewIssueChooseTemplate}}/choose{{end}}">{{.locale.Tr "repo.issues.new"}}</a>
|
||||
{{end}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue