diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-06 01:55:21 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-06 02:08:58 +0800 |
commit | faa5ca8fab23176d390e9522f1485d467851545b (patch) | |
tree | d3b1d081e0ea5e7f71a94dc1d301e2540a8abcc8 | |
parent | Slight refactor on NewServer (diff) | |
download | forge-d0b51bf88914c72ad8405c1dfccd7ada12bfeaf8.tar.gz forge-d0b51bf88914c72ad8405c1dfccd7ada12bfeaf8.tar.zst forge-d0b51bf88914c72ad8405c1dfccd7ada12bfeaf8.zip |
Move stuff into internal/unsortedv0.1.28
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | cmd/forge/main.go | 9 | ||||
-rw-r--r-- | internal/embed/.gitignore | 6 | ||||
-rw-r--r-- | internal/embed/embed.go | 10 | ||||
-rw-r--r-- | internal/render/readme.go | 2 | ||||
-rw-r--r-- | internal/unsorted/acl.go (renamed from acl.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/config.go (renamed from config.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/database.go (renamed from database.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/fedauth.go (renamed from fedauth.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/git_hooks_handle_linux.go (renamed from git_hooks_handle_linux.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/git_hooks_handle_other.go (renamed from git_hooks_handle_other.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/git_init.go (renamed from git_init.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/git_misc.go (renamed from git_misc.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/git_plumbing.go (renamed from git_plumbing.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/git_ref.go (renamed from git_ref.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_auth.go (renamed from http_auth.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_branches.go (renamed from http_handle_branches.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_group_index.go (renamed from http_handle_group_index.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_index.go (renamed from http_handle_index.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_login.go (renamed from http_handle_login.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_commit.go (renamed from http_handle_repo_commit.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_contrib_index.go (renamed from http_handle_repo_contrib_index.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_contrib_one.go (renamed from http_handle_repo_contrib_one.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_index.go (renamed from http_handle_repo_index.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_info.go (renamed from http_handle_repo_info.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_log.go (renamed from http_handle_repo_log.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_raw.go (renamed from http_handle_repo_raw.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_tree.go (renamed from http_handle_repo_tree.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_repo_upload_pack.go (renamed from http_handle_repo_upload_pack.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_handle_users.go (renamed from http_handle_users.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_server.go (renamed from http_server.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/http_template.go (renamed from http_template.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/lmtp_handle_patch.go (renamed from lmtp_handle_patch.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/lmtp_server.go (renamed from lmtp_server.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/remote_url.go (renamed from remote_url.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/resources.go (renamed from resources.go) | 15 | ||||
-rw-r--r-- | internal/unsorted/server.go (renamed from server.go) | 21 | ||||
-rw-r--r-- | internal/unsorted/ssh_handle_receive_pack.go (renamed from ssh_handle_receive_pack.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/ssh_handle_upload_pack.go (renamed from ssh_handle_upload_pack.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/ssh_server.go (renamed from ssh_server.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/ssh_utils.go (renamed from ssh_utils.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/users.go (renamed from users.go) | 2 | ||||
-rw-r--r-- | internal/unsorted/version.go (renamed from version.go) | 2 |
43 files changed, 83 insertions, 62 deletions
@@ -14,15 +14,17 @@ MAN_PAGES = lindenii-forge.5 lindenii-forge-hookc.1 lindenii-forge.1 lindenii-fo VERSION = $(shell git describe --tags --always --dirty) SOURCE_FILES = $(shell git ls-files) +EMBED = git2d/git2d hookc/hookc source.tar.gz LICENSE $(wildcard static/*) $(wildcard templates/*) +EMBED_ = $(EMBED:%=internal/embed/%) -forge: source.tar.gz hookc/hookc git2d/git2d $(SOURCE_FILES) +forge: $(EMBED_) $(SOURCE_FILES) CGO_ENABLED=0 go build -o forge -ldflags '-extldflags "-f no-PIC -static" -X "go.lindenii.runxiyu.org/forge.version=$(VERSION)"' -tags 'osusergo netgo static_build' ./cmd/forge utils/colb: hookc/hookc: -git2d/git2d: git2d/*.c +git2d/git2d: $(wildcard git2d/*.c) $(CC) $(CFLAGS) -o git2d/git2d $^ $(shell pkg-config --cflags --libs libgit2) -lpthread clean: @@ -31,3 +33,7 @@ clean: source.tar.gz: $(SOURCE_FILES) rm -f source.tar.gz git ls-files -z | xargs -0 tar -czf source.tar.gz + +internal/embed/%: % + mkdir -p $(shell dirname $@) + cp $^ $@ diff --git a/cmd/forge/main.go b/cmd/forge/main.go index 07a9bfd..5a23947 100644 --- a/cmd/forge/main.go +++ b/cmd/forge/main.go @@ -6,7 +6,7 @@ package main import ( "flag" - "go.lindenii.runxiyu.org/forge" + "go.lindenii.runxiyu.org/forge/internal/unsorted" ) func main() { @@ -17,7 +17,10 @@ func main() { ) flag.Parse() - s := forge.NewServer(*configPath) + s, err := unsorted.NewServer(*configPath) + if err != nil { + panic(err) + } - s.Run() + panic(s.Run()) } diff --git a/internal/embed/.gitignore b/internal/embed/.gitignore new file mode 100644 index 0000000..32f7aff --- /dev/null +++ b/internal/embed/.gitignore @@ -0,0 +1,6 @@ +/source.tar.gz +/hookc/hookc +/git2d/git2d +/static +/templates +/LICENSE diff --git a/internal/embed/embed.go b/internal/embed/embed.go new file mode 100644 index 0000000..76b0192 --- /dev/null +++ b/internal/embed/embed.go @@ -0,0 +1,10 @@ +package embed + +import "embed" + +//go:embed LICENSE source.tar.gz +var Source embed.FS + +//go:embed templates/* static/* +//go:embed hookc/hookc git2d/git2d +var Resources embed.FS diff --git a/internal/render/readme.go b/internal/render/readme.go index aecd2f7..ac60981 100644 --- a/internal/render/readme.go +++ b/internal/render/readme.go @@ -16,7 +16,7 @@ import ( "go.lindenii.runxiyu.org/forge/internal/misc" ) -var markdownConverter = goldmark.New(goldmark.WithExtensions(extension.GFM)) +var markdownConverter = goldmark.New(goldmark.WithExtensions(extension.GFM)) //nolint:gochecknoglobals // renderReadme renders and sanitizes README content from a byte slice and filename. func Readme(data []byte, filename string) (string, template.HTML) { diff --git a/acl.go b/internal/unsorted/acl.go index aaf190b..c2e887d 100644 --- a/acl.go +++ b/internal/unsorted/acl.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "context" diff --git a/config.go b/internal/unsorted/config.go index 8ed6eb7..a2c0eb7 100644 --- a/config.go +++ b/internal/unsorted/config.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "bufio" diff --git a/database.go b/internal/unsorted/database.go index b1aca72..222b0c4 100644 --- a/database.go +++ b/internal/unsorted/database.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "context" diff --git a/fedauth.go b/internal/unsorted/fedauth.go index 7866e58..f54649b 100644 --- a/fedauth.go +++ b/internal/unsorted/fedauth.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "bufio" diff --git a/git_hooks_handle_linux.go b/internal/unsorted/git_hooks_handle_linux.go index fa4f86f..de45e03 100644 --- a/git_hooks_handle_linux.go +++ b/internal/unsorted/git_hooks_handle_linux.go @@ -3,7 +3,7 @@ // //go:build linux -package forge +package unsorted import ( "bytes" diff --git a/git_hooks_handle_other.go b/internal/unsorted/git_hooks_handle_other.go index da40bb6..dd46622 100644 --- a/git_hooks_handle_other.go +++ b/internal/unsorted/git_hooks_handle_other.go @@ -3,7 +3,7 @@ // //go:build !linux -package forge +package unsorted import ( "bytes" diff --git a/git_init.go b/internal/unsorted/git_init.go index d1922ee..a9bba78 100644 --- a/git_init.go +++ b/internal/unsorted/git_init.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "github.com/go-git/go-git/v5" diff --git a/git_misc.go b/internal/unsorted/git_misc.go index 83ee11c..ceda3d1 100644 --- a/git_misc.go +++ b/internal/unsorted/git_misc.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "context" diff --git a/git_plumbing.go b/internal/unsorted/git_plumbing.go index 8c73a93..5cb30b7 100644 --- a/git_plumbing.go +++ b/internal/unsorted/git_plumbing.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "bytes" diff --git a/git_ref.go b/internal/unsorted/git_ref.go index 476dde0..d9735ba 100644 --- a/git_ref.go +++ b/internal/unsorted/git_ref.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "github.com/go-git/go-git/v5" diff --git a/http_auth.go b/internal/unsorted/http_auth.go index 44e087d..b0afa05 100644 --- a/http_auth.go +++ b/internal/unsorted/http_auth.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_handle_branches.go b/internal/unsorted/http_handle_branches.go index 7709d4e..04a9f31 100644 --- a/http_handle_branches.go +++ b/internal/unsorted/http_handle_branches.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_handle_group_index.go b/internal/unsorted/http_handle_group_index.go index 5d2edce..41eba24 100644 --- a/http_handle_group_index.go +++ b/internal/unsorted/http_handle_group_index.go @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "errors" diff --git a/http_handle_index.go b/internal/unsorted/http_handle_index.go index c1efd98..458fbb4 100644 --- a/http_handle_index.go +++ b/internal/unsorted/http_handle_index.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_handle_login.go b/internal/unsorted/http_handle_login.go index 4b7cacf..5386e3a 100644 --- a/http_handle_login.go +++ b/internal/unsorted/http_handle_login.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "crypto/rand" diff --git a/http_handle_repo_commit.go b/internal/unsorted/http_handle_repo_commit.go index 22ee20d..44f8f54 100644 --- a/http_handle_repo_commit.go +++ b/internal/unsorted/http_handle_repo_commit.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "fmt" diff --git a/http_handle_repo_contrib_index.go b/internal/unsorted/http_handle_repo_contrib_index.go index 7bdcb49..4db3846 100644 --- a/http_handle_repo_contrib_index.go +++ b/internal/unsorted/http_handle_repo_contrib_index.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_handle_repo_contrib_one.go b/internal/unsorted/http_handle_repo_contrib_one.go index 280dca8..fb9989b 100644 --- a/http_handle_repo_contrib_one.go +++ b/internal/unsorted/http_handle_repo_contrib_one.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_handle_repo_index.go b/internal/unsorted/http_handle_repo_index.go index b564286..f2bb480 100644 --- a/http_handle_repo_index.go +++ b/internal/unsorted/http_handle_repo_index.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_handle_repo_info.go b/internal/unsorted/http_handle_repo_info.go index 303fad7..e23b1d2 100644 --- a/http_handle_repo_info.go +++ b/internal/unsorted/http_handle_repo_info.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "fmt" diff --git a/http_handle_repo_log.go b/internal/unsorted/http_handle_repo_log.go index fbc7478..c25c60b 100644 --- a/http_handle_repo_log.go +++ b/internal/unsorted/http_handle_repo_log.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_handle_repo_raw.go b/internal/unsorted/http_handle_repo_raw.go index 286cbdf..7849d48 100644 --- a/http_handle_repo_raw.go +++ b/internal/unsorted/http_handle_repo_raw.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "fmt" diff --git a/http_handle_repo_tree.go b/internal/unsorted/http_handle_repo_tree.go index d127e5d..cbbba98 100644 --- a/http_handle_repo_tree.go +++ b/internal/unsorted/http_handle_repo_tree.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "html/template" diff --git a/http_handle_repo_upload_pack.go b/internal/unsorted/http_handle_repo_upload_pack.go index 475c0a2..df8bef4 100644 --- a/http_handle_repo_upload_pack.go +++ b/internal/unsorted/http_handle_repo_upload_pack.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "io" diff --git a/http_handle_users.go b/internal/unsorted/http_handle_users.go index 816d703..7b0f657 100644 --- a/http_handle_users.go +++ b/internal/unsorted/http_handle_users.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/http" diff --git a/http_server.go b/internal/unsorted/http_server.go index 717f223..6710df3 100644 --- a/http_server.go +++ b/internal/unsorted/http_server.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "errors" diff --git a/http_template.go b/internal/unsorted/http_template.go index d6af9fb..db44e4c 100644 --- a/http_template.go +++ b/internal/unsorted/http_template.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "log/slog" diff --git a/lmtp_handle_patch.go b/internal/unsorted/lmtp_handle_patch.go index 6841444..1a23422 100644 --- a/lmtp_handle_patch.go +++ b/internal/unsorted/lmtp_handle_patch.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "bytes" diff --git a/lmtp_server.go b/internal/unsorted/lmtp_server.go index 593dc5a..13c74c8 100644 --- a/lmtp_server.go +++ b/internal/unsorted/lmtp_server.go @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> // SPDX-FileCopyrightText: Copyright (c) 2024 Robin Jarry <robin@jarry.cc> -package forge +package unsorted import ( "bytes" diff --git a/remote_url.go b/internal/unsorted/remote_url.go index a9d8bf2..51740c4 100644 --- a/remote_url.go +++ b/internal/unsorted/remote_url.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "net/url" diff --git a/resources.go b/internal/unsorted/resources.go index 514c0ae..d09ee60 100644 --- a/resources.go +++ b/internal/unsorted/resources.go @@ -1,25 +1,18 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( - "embed" "html/template" "io/fs" "github.com/tdewolff/minify/v2" "github.com/tdewolff/minify/v2/html" + "go.lindenii.runxiyu.org/forge/internal/embed" "go.lindenii.runxiyu.org/forge/internal/misc" ) -//go:embed LICENSE source.tar.gz -var embeddedSourceFS embed.FS - -//go:embed templates/* static/* -//go:embed hookc/hookc git2d/git2d -var embeddedResourcesFS embed.FS - // loadTemplates minifies and loads HTML templates. func (s *Server) loadTemplates() (err error) { minifier := minify.New() @@ -37,12 +30,12 @@ func (s *Server) loadTemplates() (err error) { "minus": misc.Minus, }) - err = fs.WalkDir(embeddedResourcesFS, "templates", func(path string, d fs.DirEntry, err error) error { + err = fs.WalkDir(embed.Resources, "templates", func(path string, d fs.DirEntry, err error) error { if err != nil { return err } if !d.IsDir() { - content, err := fs.ReadFile(embeddedResourcesFS, path) + content, err := fs.ReadFile(embed.Resources, path) if err != nil { return err } diff --git a/server.go b/internal/unsorted/server.go index 3a90e1c..12da5cb 100644 --- a/server.go +++ b/internal/unsorted/server.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "errors" @@ -18,6 +18,7 @@ import ( "time" "go.lindenii.runxiyu.org/forge/internal/database" + "go.lindenii.runxiyu.org/forge/internal/embed" "go.lindenii.runxiyu.org/forge/internal/irc" "go.lindenii.runxiyu.org/forge/internal/misc" "go.lindenii.runxiyu.org/lindenii-common/cmap" @@ -49,18 +50,20 @@ type Server struct { ready bool } -func (s *Server) NewServer(configPath string) error { +func NewServer(configPath string) (*Server, error) { + s := &Server{} + if err := s.loadConfig(configPath); err != nil { - return err + return s, err } s.sourceHandler = http.StripPrefix( "/-/source/", - http.FileServer(http.FS(embeddedSourceFS)), + http.FileServer(http.FS(embed.Source)), ) - staticFS, err := fs.Sub(embeddedResourcesFS, "static") + staticFS, err := fs.Sub(embed.Resources, "static") if err != nil { - return err + return s, err } s.staticHandler = http.StripPrefix("/-/static/", http.FileServer(http.FS(staticFS))) s.globalData = map[string]any{ @@ -71,13 +74,13 @@ func (s *Server) NewServer(configPath string) error { } misc.NoneOrPanic(s.loadTemplates()) - misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embeddedResourcesFS.Open("git2d/git2d")), s.config.Git.DaemonPath)) - misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embeddedResourcesFS.Open("hookc/hookc")), filepath.Join(s.config.Hooks.Execs, "pre-receive"))) + misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embed.Resources.Open("git2d/git2d")), s.config.Git.DaemonPath)) + misc.NoneOrPanic(misc.DeployBinary(misc.FirstOrPanic(embed.Resources.Open("hookc/hookc")), filepath.Join(s.config.Hooks.Execs, "pre-receive"))) misc.NoneOrPanic(os.Chmod(filepath.Join(s.config.Hooks.Execs, "pre-receive"), 0o755)) s.ready = true - return nil + return s, nil } func (s *Server) Run() error { diff --git a/ssh_handle_receive_pack.go b/internal/unsorted/ssh_handle_receive_pack.go index de6843a..a354273 100644 --- a/ssh_handle_receive_pack.go +++ b/internal/unsorted/ssh_handle_receive_pack.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "errors" diff --git a/ssh_handle_upload_pack.go b/internal/unsorted/ssh_handle_upload_pack.go index 34a1d9e..735a053 100644 --- a/ssh_handle_upload_pack.go +++ b/internal/unsorted/ssh_handle_upload_pack.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "fmt" diff --git a/ssh_server.go b/internal/unsorted/ssh_server.go index 45ed703..eb4d09d 100644 --- a/ssh_server.go +++ b/internal/unsorted/ssh_server.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "fmt" diff --git a/ssh_utils.go b/internal/unsorted/ssh_utils.go index 7aeedff..d9850d2 100644 --- a/ssh_utils.go +++ b/internal/unsorted/ssh_utils.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "context" diff --git a/users.go b/internal/unsorted/users.go index 2b529f3..0f72eed 100644 --- a/users.go +++ b/internal/unsorted/users.go @@ -1,7 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only // SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org> -package forge +package unsorted import ( "context" diff --git a/version.go b/internal/unsorted/version.go index 555fe2a..fccf52c 100644 --- a/version.go +++ b/internal/unsorted/version.go @@ -1,3 +1,3 @@ -package forge +package unsorted var version = "unknown" |