fix missing files from legit
This commit is contained in:
22
cmd/legit/contrib/Dockerfile
Normal file
22
cmd/legit/contrib/Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
FROM golang:1.22-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN go mod download
|
||||||
|
RUN go mod verify
|
||||||
|
|
||||||
|
RUN go build -o legit
|
||||||
|
|
||||||
|
FROM scratch AS build-release-stage
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY static ./static
|
||||||
|
COPY templates ./templates
|
||||||
|
COPY config.yaml ./
|
||||||
|
COPY --from=builder /app/legit ./
|
||||||
|
|
||||||
|
EXPOSE 5555
|
||||||
|
|
||||||
|
CMD ["./legit"]
|
||||||
26
cmd/legit/flake.lock
generated
Normal file
26
cmd/legit/flake.lock
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1718558927,
|
||||||
|
"narHash": "sha256-PRqvkPqX5luuZ0WcUbz2zATGp4IzybDU0K33MxO9Sd0=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "f82fe275d98c521c051af4892cd8b3406cee67a3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
62
cmd/legit/flake.nix
Normal file
62
cmd/legit/flake.nix
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
description = "web frontend for git";
|
||||||
|
|
||||||
|
inputs.nixpkgs.url = "github:nixos/nixpkgs";
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ self
|
||||||
|
, nixpkgs
|
||||||
|
,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = forAllSystems (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgsFor.${system};
|
||||||
|
legit = self.packages.${system}.legit;
|
||||||
|
files = pkgs.lib.fileset.toSource {
|
||||||
|
root = ./.;
|
||||||
|
fileset = pkgs.lib.fileset.unions [
|
||||||
|
./config.yaml
|
||||||
|
./static
|
||||||
|
./templates
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
legit = pkgs.buildGoModule {
|
||||||
|
name = "legit";
|
||||||
|
rev = "master";
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
vendorHash = "sha256-ynv0pBdVPIhTz7RvCwVWr0vUWwfw+PEjFXs9PdQMqm8=";
|
||||||
|
};
|
||||||
|
docker = pkgs.dockerTools.buildLayeredImage {
|
||||||
|
name = "sini:5000/legit";
|
||||||
|
tag = "latest";
|
||||||
|
contents = [ files legit pkgs.git ];
|
||||||
|
config = {
|
||||||
|
Entrypoint = [ "${legit}/bin/legit" ];
|
||||||
|
ExposedPorts = { "5555/tcp" = { }; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
defaultPackage = forAllSystems (system: self.packages.${system}.legit);
|
||||||
|
devShells = forAllSystems (system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgsFor.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
go
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
module git.icyphox.sh/legit
|
module realy.lol/cmd/legit
|
||||||
|
|
||||||
go 1.22.0
|
go 1.22.0
|
||||||
|
|
||||||
|
|||||||
23
cmd/legit/license
Normal file
23
cmd/legit/license
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) Anirudh Oppiliappan <x@icyphox.sh>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.icyphox.sh/legit/config"
|
"realy.lol/cmd/legit/config"
|
||||||
"git.icyphox.sh/legit/routes"
|
"realy.lol/cmd/legit/routes"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
88
cmd/legit/readme
Normal file
88
cmd/legit/readme
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
legit
|
||||||
|
-----
|
||||||
|
|
||||||
|
A git web frontend written in Go.
|
||||||
|
|
||||||
|
Pronounced however you like; I prefer channeling my inner beret-wearing
|
||||||
|
Frenchman, and saying "Oui, il est le git!"
|
||||||
|
|
||||||
|
But yeah it's pretty legit, no cap on god fr fr.
|
||||||
|
|
||||||
|
|
||||||
|
FEATURES
|
||||||
|
|
||||||
|
• Fully customizable templates and stylesheets.
|
||||||
|
• Cloning over http(s).
|
||||||
|
• Less archaic HTML.
|
||||||
|
• Not CGI.
|
||||||
|
|
||||||
|
|
||||||
|
INSTALLING
|
||||||
|
|
||||||
|
Clone it, 'go build' it.
|
||||||
|
|
||||||
|
|
||||||
|
CONFIG
|
||||||
|
|
||||||
|
Uses yaml for configuration. Looks for a 'config.yaml' in the current
|
||||||
|
directory by default; pass the '--config' flag to point it elsewhere.
|
||||||
|
|
||||||
|
Example config.yaml:
|
||||||
|
|
||||||
|
repo:
|
||||||
|
scanPath: /var/www/git
|
||||||
|
readme:
|
||||||
|
- readme
|
||||||
|
- README
|
||||||
|
- readme.md
|
||||||
|
- README.md
|
||||||
|
mainBranch:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
ignore:
|
||||||
|
- foo
|
||||||
|
- bar
|
||||||
|
dirs:
|
||||||
|
templates: ./templates
|
||||||
|
static: ./static
|
||||||
|
meta:
|
||||||
|
title: git good
|
||||||
|
description: i think it's a skill issue
|
||||||
|
syntaxHighlight: monokailight
|
||||||
|
server:
|
||||||
|
name: git.icyphox.sh
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 5555
|
||||||
|
|
||||||
|
These options are fairly self-explanatory, but of note are:
|
||||||
|
|
||||||
|
• repo.scanPath: where all your git repos live (or die). legit doesn't
|
||||||
|
traverse subdirs yet.
|
||||||
|
• dirs: use this to override the default templates and static assets.
|
||||||
|
• repo.readme: readme files to look for.
|
||||||
|
• repo.mainBranch: main branch names to look for.
|
||||||
|
• repo.ignore: repos to ignore, relative to scanPath.
|
||||||
|
• repo.unlisted: repos to hide, relative to scanPath.
|
||||||
|
• server.name: used for go-import meta tags and clone URLs.
|
||||||
|
• meta.syntaxHighlight: this is used to select the syntax theme to render. If left
|
||||||
|
blank or removed, the native theme will be used. If an invalid theme is set in this field,
|
||||||
|
it will default to "monokailight". For more information
|
||||||
|
about themes, please refer to chroma's gallery [1].
|
||||||
|
|
||||||
|
|
||||||
|
NOTES
|
||||||
|
|
||||||
|
• Run legit behind a TLS terminating proxy like relayd(8) or nginx.
|
||||||
|
• Cloning only works in bare repos -- this is a limitation inherent to git. You
|
||||||
|
can still view non-bare repos just fine in legit.
|
||||||
|
• Pushing over https, while supported, is disabled because auth is a
|
||||||
|
pain. Use ssh.
|
||||||
|
• Paths are unveil(2)'d on OpenBSD.
|
||||||
|
• Docker images are available ghcr.io/icyphox/legit:{master,latest,vX.Y.Z}. [2]
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
legit is licensed under MIT.
|
||||||
|
|
||||||
|
[1]: https://swapoff.org/chroma/playground/
|
||||||
|
[2]: https://github.com/icyphox/legit/pkgs/container/legit
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
securejoin "github.com/cyphar/filepath-securejoin"
|
securejoin "github.com/cyphar/filepath-securejoin"
|
||||||
|
|
||||||
"git.icyphox.sh/legit/git/service"
|
"realy.lol/cmd/legit/git/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *deps) InfoRefs(w http.ResponseWriter, r *http.Request) {
|
func (d *deps) InfoRefs(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package routes
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.icyphox.sh/legit/config"
|
"realy.lol/cmd/legit/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Checks for gitprotocol-http(5) specific smells; if found, passes
|
// Checks for gitprotocol-http(5) specific smells; if found, passes
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ import (
|
|||||||
"github.com/microcosm-cc/bluemonday"
|
"github.com/microcosm-cc/bluemonday"
|
||||||
"github.com/russross/blackfriday/v2"
|
"github.com/russross/blackfriday/v2"
|
||||||
|
|
||||||
"git.icyphox.sh/legit/config"
|
"realy.lol/cmd/legit/config"
|
||||||
"git.icyphox.sh/legit/git"
|
"realy.lol/cmd/legit/git"
|
||||||
)
|
)
|
||||||
|
|
||||||
type deps struct {
|
type deps struct {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/alecthomas/chroma/v2/lexers"
|
"github.com/alecthomas/chroma/v2/lexers"
|
||||||
"github.com/alecthomas/chroma/v2/styles"
|
"github.com/alecthomas/chroma/v2/styles"
|
||||||
|
|
||||||
"git.icyphox.sh/legit/git"
|
"realy.lol/cmd/legit/git"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *deps) Write404(w http.ResponseWriter) {
|
func (d *deps) Write404(w http.ResponseWriter) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.icyphox.sh/legit/git"
|
"realy.lol/cmd/legit/git"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isGoModule(gr *git.GitRepo) bool {
|
func isGoModule(gr *git.GitRepo) bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user