web frontend for git repositories, written in Go git.pocka.jp/legit.git
3

Configure Feed

Select the types of activity you want to include in your feed.

Setup load testing

It's minimal, but useful for future additions.

Considering the current trend of malcious crawlers, I believe this is
necessary.

Shota FUJI (Jul 12, 2026, 11:29 PM +0900) 912daf3f 3ce7ca00

+213
+25
DEVELOPMENT.md
··· 1 + <!-- 2 + Copyright 2026 Shota FUJI <pockawoooh@gmail.com> 3 + SPDX-License-Identifier: MIT 4 + --> 5 + 6 + # Development 7 + 8 + Commands and tips for developing legit. 9 + 10 + ## Load Testing 11 + 12 + `tests/k6` directory contains `*.js` for [k6](https://grafana.com/oss/k6/), an OSS load testing tool. 13 + 14 + These test files access a test server on localhost:8080. 15 + Run `nix run .#testing` (you need Nix Flakes) or follow steps described in `tests/k6/.gitignore` manually (you need bash, git, and built `legit` binary) to launch the test server. 16 + 17 + Once the test server is ready, pass your desired test file to `k6 run` command. 18 + Nix user can use `nix run .#k6 -- run` without installing k6 manually. 19 + 20 + ## Code Formatting 21 + 22 + This project use [dprint](https://dprint.dev/). 23 + You have to install [`nixfmt`](https://github.com/NixOS/nixfmt) and Go toolchain as well. 24 + 25 + Nix user can run `nix fmt` without installing or configuring anything.
+28
flake.nix
··· 47 47 48 48 default = legit; 49 49 50 + testing = 51 + let 52 + repos = pkgs.callPackage ./tests/k6/repos.nix { }; 53 + in 54 + pkgs.writeShellApplication { 55 + name = "legit-testing"; 56 + 57 + text = '' 58 + ${pkgs.lib.getExe legit} -config ${repos}/tests/k6/config.yaml 59 + ''; 60 + 61 + runtimeInputs = with pkgs; [ 62 + git 63 + legit 64 + 65 + repos 66 + ]; 67 + }; 68 + 50 69 docker = pkgs.dockerTools.buildLayeredImage { 51 70 name = "sini:5000/legit"; 52 71 tag = "latest"; ··· 61 80 "5555/tcp" = { }; 62 81 }; 63 82 }; 83 + }; 84 + } 85 + ); 86 + 87 + apps = forAllSystems ( 88 + { system, pkgs }: { 89 + k6 = { 90 + type = "app"; 91 + program = pkgs.lib.getExe pkgs.k6; 64 92 }; 65 93 } 66 94 );
+10
tests/k6/.gitignore
··· 1 + # Copyright 2026 Shota FUJI <pockawoooh@gmail.com> 2 + # SPDX-License-Identifier: MIT 3 + 4 + # Test repositories. To manually run test server, run below: 5 + # mkdir repos 6 + # cd repos 7 + # bash ../create_repos.bash 8 + # cd .. 9 + # ../../legit -config config.yaml 10 + /repos
+22
tests/k6/config.yaml
··· 1 + # Copyright 2026 Shota FUJI <pockawoooh@gmail.com> 2 + # SPDX-License-Identifier: MIT 3 + 4 + repo: 5 + scanPath: repos 6 + readme: 7 + - README.md 8 + mainBranch: 9 + - trunk 10 + 11 + dirs: 12 + templates: ../../templates 13 + static: ../../static 14 + 15 + meta: 16 + title: Legit Load Testing 17 + syntaxHighlight: true 18 + 19 + server: 20 + name: example.com 21 + host: localhost 22 + port: 8080
+68
tests/k6/create_repos.bash
··· 1 + # create_repos.bash 2 + # Bash script to create sample repos in the current directory. 3 + # 4 + # Copyright 2026 Shota FUJI <pockawoooh@gmail.com> 5 + # SPDX-License-Identifier: MIT 6 + 7 + # Usage 8 + # cd test_dir 9 + # bash /path/to/create_repos.bash 10 + 11 + set -e 12 + 13 + # To get deterministic output. 14 + export GIT_CONFIG_GLOBAL=/dev/null 15 + export GIT_CONFIG_SYSTEM=/dev/null 16 + export GIT_COMMITTER_DATE="2026-06-30T09:00:00+09:00" 17 + 18 + GIT_FLAGS=( 19 + "-c" "user.name=Alice" 20 + "-c" "user.email=alice@example.com" 21 + "-c" "init.defaultBranch=trunk" 22 + ) 23 + 24 + # foo - basic sample 25 + git ${GIT_FLAGS[@]} init foo 26 + 27 + cat <<EOF > foo/README.md 28 + # Foo 29 + 30 + This is foo. 31 + I'm [Markdown](https://commonmark.org/) file for *load* **testing**. 32 + 33 + ``` 34 + This file is to test Markdown rendering performance of summary page. 35 + ``` 36 + 37 + * longer 38 + * the 39 + * contents 40 + * and 41 + * more 42 + + readable 43 + + comparable 44 + * output 45 + EOF 46 + git ${GIT_FLAGS[@]} -C foo add README.md 47 + git ${GIT_FLAGS[@]} -C foo commit \ 48 + -m "Add README" \ 49 + --date "2026-06-06T12:00:00+09:00" 50 + 51 + cat <<EOF > foo/main.go 52 + package main 53 + 54 + import ( 55 + "fmt" 56 + ) 57 + 58 + func main() { 59 + fmt.Println("Hello, World!") 60 + } 61 + EOF 62 + git ${GIT_FLAGS[@]} -C foo add main.go 63 + git ${GIT_FLAGS[@]} -C foo commit \ 64 + -m "Create Go application entrypoint" \ 65 + --date "2026-06-06T12:01:00+09:00" 66 + 67 + git clone --bare foo foo.git 68 + rm -rf foo
+36
tests/k6/repos.nix
··· 1 + # Copyright 2026 Shota FUJI <pockawoooh@gmail.com> 2 + # SPDX-License-Identifier: MIT 3 + 4 + { 5 + lib, 6 + stdenv, 7 + bash, 8 + git, 9 + }: 10 + stdenv.mkDerivation { 11 + name = "legit-test-repos"; 12 + 13 + src = lib.fileset.toSource { 14 + root = ../../.; 15 + fileset = lib.fileset.unions [ 16 + ./create_repos.bash 17 + ./config.yaml 18 + ../../static 19 + ../../templates 20 + ]; 21 + }; 22 + 23 + postInstall = '' 24 + mkdir -p $out/tests/k6/repos 25 + cd $out/tests/k6/repos 26 + bash $src/tests/k6/create_repos.bash 27 + ln -s $src/tests/k6/config.yaml $out/tests/k6/config.yaml 28 + ln -s $src/static $out/static 29 + ln -s $src/templates $out/templates 30 + ''; 31 + 32 + nativeBuildInputs = [ 33 + bash 34 + git 35 + ]; 36 + }
+12
tests/k6/spam_repo_list.js
··· 1 + // Copyright 2026 Shota FUJI <pockawoooh@gmail.com> 2 + // SPDX-License-Identifier: MIT 3 + 4 + import http from "k6/http"; 5 + 6 + export const options = { 7 + iterations: 10, 8 + }; 9 + 10 + export default function() { 11 + http.get("http://localhost:8080"); 12 + }
+12
tests/k6/spam_repo_summary.js
··· 1 + // Copyright 2026 Shota FUJI <pockawoooh@gmail.com> 2 + // SPDX-License-Identifier: MIT 3 + 4 + import http from "k6/http"; 5 + 6 + export const options = { 7 + iterations: 10, 8 + }; 9 + 10 + export default function() { 11 + http.get("http://localhost:8080/foo.git"); 12 + }