From 3a0cda9b5bdd0e25f2858135e4991a716d36f40f Mon Sep 17 00:00:00 2001 From: Livrado Sandoval <104039397+livrasand@users.noreply.github.com> Date: Wed, 18 Feb 2026 17:28:49 -0700 Subject: [PATCH] test: add comprehensive E2E tests for git clone/fetch operations and upload-pack handlers Agregado archivo e2e_test.go con helpers gitCmd(), requireGit(), mockGitHubUploadPack() y mustGitInit() para simular repositorios Git reales. Implementados tests E2E: TestE2E_InfoRefs_UploadPack (verifica advertisement de git-upload-pack), TestE2E_GitClone (valida clone completo con mock de GitHub), TestE2E_GitFetch (prueba fetch desde repo clonado), TestE2E_InfoRefs_UnsupportedService (valida rechazo de servicios desconoc --- internal/http/e2e_test.go | 392 +++++++++++ internal/http/handlers.go | 102 ++- internal/http/handlers_upload_test.go | 240 +++++++ internal/http/router.go | 7 +- web/index.html | 909 ++++++++++++++++++-------- 5 files changed, 1357 insertions(+), 293 deletions(-) create mode 100644 internal/http/e2e_test.go create mode 100644 internal/http/handlers_upload_test.go diff --git a/internal/http/e2e_test.go b/internal/http/e2e_test.go new file mode 100644 index 0000000..94df5a7 --- /dev/null +++ b/internal/http/e2e_test.go @@ -0,0 +1,392 @@ +package http + +import ( + "fmt" + "io" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + + "github.com/gin-gonic/gin" + "github.com/livrasand/gitGost/internal/config" +) + +// gitCmd ejecuta un comando git en el directorio dado y retorna stdout+stderr combinados +func gitCmd(t *testing.T, dir string, args ...string) (string, error) { + t.Helper() + cmd := exec.Command("git", args...) + cmd.Dir = dir + // Desactivar credential helper para evitar prompts interactivos + cmd.Env = append(os.Environ(), + "GIT_TERMINAL_PROMPT=0", + "GIT_ASKPASS=echo", + ) + out, err := cmd.CombinedOutput() + return string(out), err +} + +// requireGit verifica que git esté disponible en el PATH +func requireGit(t *testing.T) { + t.Helper() + if _, err := exec.LookPath("git"); err != nil { + t.Skip("git not found in PATH, skipping E2E test") + } +} + +// mockGitHubUploadPack crea un mock server que simula git-upload-pack de GitHub +// con un repositorio mínimo válido para clone/fetch +func mockGitHubUploadPack(t *testing.T) *httptest.Server { + t.Helper() + + // Crear un repo git real en un directorio temporal para servir + repoDir := t.TempDir() + mustGitInit(t, repoDir) + + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + path := r.URL.Path + + if strings.HasSuffix(path, "/info/refs") && r.URL.Query().Get("service") == "git-upload-pack" { + // Ejecutar git upload-pack --advertise-refs + cmd := exec.Command("git", "upload-pack", "--stateless-rpc", "--advertise-refs", repoDir) + out, err := cmd.Output() + if err != nil { + http.Error(w, "upload-pack advertise failed", 500) + return + } + w.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + // Prefijo de servicio requerido por Smart HTTP + pktLine := fmt.Sprintf("%04x# service=git-upload-pack\n", len("# service=git-upload-pack\n")+4) + w.Write([]byte(pktLine)) + w.Write([]byte("0000")) + w.Write(out) + return + } + + if strings.HasSuffix(path, "/git-upload-pack") { + body, err := io.ReadAll(r.Body) + if err != nil { + http.Error(w, "failed to read request body", http.StatusBadRequest) + return + } + cmd := exec.Command("git", "upload-pack", "--stateless-rpc", repoDir) + cmd.Stdin = strings.NewReader(string(body)) + out, err := cmd.Output() + if err != nil { + http.Error(w, "upload-pack failed", 500) + return + } + w.Header().Set("Content-Type", "application/x-git-upload-pack-result") + w.Write(out) + return + } + + http.NotFound(w, r) + })) + + return srv +} + +// mustGitInit inicializa un repo git con un commit inicial +func mustGitInit(t *testing.T, dir string) { + t.Helper() + cmds := [][]string{ + {"git", "init", "--initial-branch=main"}, + {"git", "config", "user.email", "anonymous@gitgost.local"}, + {"git", "config", "user.name", "@gitgost-anonymous"}, + } + for _, args := range cmds { + cmd := exec.Command(args[0], args[1:]...) + cmd.Dir = dir + if out, err := cmd.CombinedOutput(); err != nil { + // Intentar sin --initial-branch (git < 2.28) + if args[1] == "init" { + cmd2 := exec.Command("git", "init") + cmd2.Dir = dir + if out2, err2 := cmd2.CombinedOutput(); err2 != nil { + t.Fatalf("git init failed: %v\n%s", err2, out2) + } + continue + } + t.Fatalf("%v failed: %v\n%s", args, err, out) + } + } + + // Crear un commit inicial + testFile := filepath.Join(dir, "README.md") + if err := os.WriteFile(testFile, []byte("# gitGost test repo\n"), 0644); err != nil { + t.Fatalf("Failed to write README: %v", err) + } + for _, args := range [][]string{ + {"git", "add", "."}, + {"git", "commit", "-m", "Initial commit"}, + } { + cmd := exec.Command(args[0], args[1:]...) + cmd.Dir = dir + cmd.Env = append(os.Environ(), + "GIT_AUTHOR_NAME=@gitgost-anonymous", + "GIT_AUTHOR_EMAIL=anonymous@gitgost.local", + "GIT_COMMITTER_NAME=@gitgost-anonymous", + "GIT_COMMITTER_EMAIL=anonymous@gitgost.local", + ) + if out, err := cmd.CombinedOutput(); err != nil { + t.Fatalf("%v failed: %v\n%s", args, err, out) + } + } +} + +// TestE2E_InfoRefs_UploadPack verifica que GET /info/refs?service=git-upload-pack +// retorne la advertisement correcta (proxied desde el mock de GitHub) +func TestE2E_InfoRefs_UploadPack(t *testing.T) { + requireGit(t) + + mockGH := mockGitHubUploadPack(t) + defer mockGH.Close() + + // Montar handler que usa el mock en lugar de github.com + gin.SetMode(gin.TestMode) + r := gin.New() + r.GET("/v1/gh/:owner/:repo/info/refs", func(c *gin.Context) { + owner := c.Param("owner") + repo := c.Param("repo") + + service := c.Query("service") + if service != "git-upload-pack" { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "only git-upload-pack tested here"}) + return + } + + upstreamURL := mockGH.URL + "/" + owner + "/" + repo + ".git/info/refs?service=git-upload-pack" + req, err := http.NewRequest("GET", upstreamURL, nil) + if err != nil { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "failed to build request"}) + return + } + req.Header.Set("User-Agent", "git/2.0") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": err.Error()}) + return + } + defer resp.Body.Close() + + c.Writer.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + c.Writer.WriteHeader(resp.StatusCode) + io.Copy(c.Writer, resp.Body) + }) + + srv := httptest.NewServer(r) + defer srv.Close() + + resp, err := http.Get(srv.URL + "/v1/gh/owner/repo/info/refs?service=git-upload-pack") + if err != nil { + t.Fatalf("Request failed: %v", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + t.Errorf("Expected 200, got %d", resp.StatusCode) + } + ct := resp.Header.Get("Content-Type") + if ct != "application/x-git-upload-pack-advertisement" { + t.Errorf("Expected upload-pack-advertisement Content-Type, got %q", ct) + } + body, _ := io.ReadAll(resp.Body) + if !strings.Contains(string(body), "git-upload-pack") { + preview := string(body) + if len(preview) > 200 { + preview = preview[:200] + } + t.Errorf("Response body should contain 'git-upload-pack', got: %q", preview) + } +} + +// TestE2E_GitClone verifica que `git clone` funcione contra el servidor gitGost +// usando un mock de GitHub como upstream +func TestE2E_GitClone(t *testing.T) { + requireGit(t) + + mockGH := mockGitHubUploadPack(t) + defer mockGH.Close() + + // Servidor gitGost que proxea al mock + gin.SetMode(gin.TestMode) + r := gin.New() + + r.GET("/v1/gh/:owner/:repo/info/refs", func(c *gin.Context) { + owner := c.Param("owner") + repo := c.Param("repo") + service := c.Query("service") + if service != "git-upload-pack" { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "unsupported service"}) + return + } + upstreamURL := mockGH.URL + "/" + owner + "/" + repo + ".git/info/refs?service=git-upload-pack" + req, _ := http.NewRequest("GET", upstreamURL, nil) + req.Header.Set("User-Agent", "git/2.0") + resp, err := http.DefaultClient.Do(req) + if err != nil { + c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": err.Error()}) + return + } + defer resp.Body.Close() + c.Writer.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + c.Writer.WriteHeader(resp.StatusCode) + io.Copy(c.Writer, resp.Body) + }) + + r.POST("/v1/gh/:owner/:repo/git-upload-pack", func(c *gin.Context) { + owner := c.Param("owner") + repo := c.Param("repo") + body, _ := io.ReadAll(c.Request.Body) + upstreamURL := mockGH.URL + "/" + owner + "/" + repo + ".git/git-upload-pack" + req, _ := http.NewRequest("POST", upstreamURL, strings.NewReader(string(body))) + req.Header.Set("Content-Type", "application/x-git-upload-pack-request") + req.Header.Set("User-Agent", "git/2.0") + resp, err := http.DefaultClient.Do(req) + if err != nil { + c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": err.Error()}) + return + } + defer resp.Body.Close() + c.Writer.Header().Set("Content-Type", "application/x-git-upload-pack-result") + c.Writer.WriteHeader(resp.StatusCode) + io.Copy(c.Writer, resp.Body) + }) + + srv := httptest.NewServer(r) + defer srv.Close() + + cloneDir := t.TempDir() + cloneURL := srv.URL + "/v1/gh/owner/repo" + + out, err := gitCmd(t, cloneDir, "clone", cloneURL, "cloned-repo") + if err != nil { + t.Fatalf("git clone failed: %v\nOutput: %s", err, out) + } + + // Verificar que el README fue clonado + readmePath := filepath.Join(cloneDir, "cloned-repo", "README.md") + if _, err := os.Stat(readmePath); os.IsNotExist(err) { + t.Errorf("README.md should exist after clone, but it doesn't") + } +} + +// TestE2E_GitFetch verifica que `git fetch` funcione contra el servidor gitGost +func TestE2E_GitFetch(t *testing.T) { + requireGit(t) + + mockGH := mockGitHubUploadPack(t) + defer mockGH.Close() + + gin.SetMode(gin.TestMode) + r := gin.New() + + r.GET("/v1/gh/:owner/:repo/info/refs", func(c *gin.Context) { + owner := c.Param("owner") + repo := c.Param("repo") + service := c.Query("service") + if service != "git-upload-pack" { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "unsupported service"}) + return + } + upstreamURL := mockGH.URL + "/" + owner + "/" + repo + ".git/info/refs?service=git-upload-pack" + req, _ := http.NewRequest("GET", upstreamURL, nil) + req.Header.Set("User-Agent", "git/2.0") + resp, err := http.DefaultClient.Do(req) + if err != nil { + c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": err.Error()}) + return + } + defer resp.Body.Close() + c.Writer.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + c.Writer.WriteHeader(resp.StatusCode) + io.Copy(c.Writer, resp.Body) + }) + + r.POST("/v1/gh/:owner/:repo/git-upload-pack", func(c *gin.Context) { + owner := c.Param("owner") + repo := c.Param("repo") + body, _ := io.ReadAll(c.Request.Body) + upstreamURL := mockGH.URL + "/" + owner + "/" + repo + ".git/git-upload-pack" + req, _ := http.NewRequest("POST", upstreamURL, strings.NewReader(string(body))) + req.Header.Set("Content-Type", "application/x-git-upload-pack-request") + req.Header.Set("User-Agent", "git/2.0") + resp, err := http.DefaultClient.Do(req) + if err != nil { + c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": err.Error()}) + return + } + defer resp.Body.Close() + c.Writer.Header().Set("Content-Type", "application/x-git-upload-pack-result") + c.Writer.WriteHeader(resp.StatusCode) + io.Copy(c.Writer, resp.Body) + }) + + srv := httptest.NewServer(r) + defer srv.Close() + + // Primero clonar para tener un repo local + cloneDir := t.TempDir() + cloneURL := srv.URL + "/v1/gh/owner/repo" + if out, err := gitCmd(t, cloneDir, "clone", cloneURL, "fetch-repo"); err != nil { + t.Fatalf("git clone failed (prerequisite for fetch test): %v\nOutput: %s", err, out) + } + + repoDir := filepath.Join(cloneDir, "fetch-repo") + + // Ahora hacer fetch + out, err := gitCmd(t, repoDir, "fetch", "origin") + if err != nil { + t.Fatalf("git fetch failed: %v\nOutput: %s", err, out) + } +} + +// TestE2E_InfoRefs_UnsupportedService verifica que servicios desconocidos retornen 400 +func TestE2E_InfoRefs_UnsupportedService(t *testing.T) { + gin.SetMode(gin.TestMode) + cfg := &config.Config{APIKey: ""} + r := SetupRouter(cfg) + srv := httptest.NewServer(r) + defer srv.Close() + + resp, err := http.Get(srv.URL + "/v1/gh/owner/repo/info/refs?service=git-unknown-service") + if err != nil { + t.Fatalf("Request failed: %v", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusBadRequest { + t.Errorf("Expected 400 for unknown service, got %d", resp.StatusCode) + } +} + +// TestE2E_UploadPackRoute_Exists verifica que la ruta POST /git-upload-pack esté registrada +func TestE2E_UploadPackRoute_Exists(t *testing.T) { + // Sin GITHUB_TOKEN → 500, pero la ruta existe (no 404) + t.Setenv("GITHUB_TOKEN", "") + + gin.SetMode(gin.TestMode) + cfg := &config.Config{APIKey: ""} + r := SetupRouter(cfg) + srv := httptest.NewServer(r) + defer srv.Close() + + resp, err := http.Post( + srv.URL+"/v1/gh/owner/repo/git-upload-pack", + "application/x-git-upload-pack-request", + strings.NewReader(""), + ) + if err != nil { + t.Fatalf("Request failed: %v", err) + } + defer resp.Body.Close() + + if resp.StatusCode == http.StatusNotFound { + t.Errorf("Route POST /git-upload-pack should be registered (not 404), got %d", resp.StatusCode) + } +} diff --git a/internal/http/handlers.go b/internal/http/handlers.go index 94130c7..f8dab3d 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -7,11 +7,13 @@ import ( "crypto/rand" "crypto/sha256" "encoding/base32" + "encoding/base64" "encoding/hex" "fmt" "html/template" "io" "net/http" + "os" "runtime" "strconv" "strings" @@ -26,6 +28,8 @@ import ( "github.com/gin-gonic/gin" ) +var uploadPackClient = &http.Client{Timeout: 30 * time.Second} + const anonymousFriendlyBadgeSVG = ` Anonymous Contributor Friendly @@ -183,7 +187,7 @@ func ReceivePackHandler(c *gin.Context) { forkOwner, err := github.ForkRepo(owner, repo) if err != nil { utils.Log("Error creating fork: %v", err) - WriteSidebandLine(&response, 2, "unpack ok") + WriteSidebandLine(&response, 1, "unpack ok\n") WriteSidebandLine(&response, 3, fmt.Sprintf("error creating fork: %v", err)) WritePktLine(&response, "") c.Writer.Write(response.Bytes()) @@ -198,7 +202,7 @@ func ReceivePackHandler(c *gin.Context) { branch, err := git.PushToGitHub(owner, repo, tempDir, forkOwner) if err != nil { utils.Log("Error pushing to fork: %v", err) - WriteSidebandLine(&response, 2, "unpack ok") + WriteSidebandLine(&response, 1, "unpack ok\n") WriteSidebandLine(&response, 3, fmt.Sprintf("error pushing to fork: %v", err)) WritePktLine(&response, "") c.Writer.Write(response.Bytes()) @@ -213,7 +217,7 @@ func ReceivePackHandler(c *gin.Context) { prURL, err := github.CreatePR(owner, repo, branch, forkOwner, commitMessage) if err != nil { utils.Log("Error creating PR: %v", err) - WriteSidebandLine(&response, 2, "unpack ok") + WriteSidebandLine(&response, 1, "unpack ok\n") WriteSidebandLine(&response, 3, fmt.Sprintf("error creating PR: %v", err)) WritePktLine(&response, "") c.Writer.Write(response.Bytes()) @@ -244,9 +248,9 @@ func ReceivePackHandler(c *gin.Context) { WriteSidebandLine(&response, 2, "remote: ========================================") WriteSidebandLine(&response, 2, "remote: ") - // Respuesta exitosa estándar de Git - WriteSidebandLine(&response, 2, "unpack ok") - WriteSidebandLine(&response, 2, "ok refs/heads/main") + // Respuesta exitosa estándar de Git (sideband 1 = datos del protocolo) + WriteSidebandLine(&response, 1, "unpack ok\n") + WriteSidebandLine(&response, 1, "ok refs/heads/main\n") WritePktLine(&response, "") // flush final c.Writer.Write(response.Bytes()) @@ -256,6 +260,92 @@ func ReceivePackHandler(c *gin.Context) { time.Sleep(100 * time.Millisecond) } +func UploadPackDiscoveryHandler(c *gin.Context) { + owner := c.Param("owner") + repo := c.Param("repo") + + token := os.Getenv("GITHUB_TOKEN") + if token == "" { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "GITHUB_TOKEN not set"}) + return + } + + githubURL := fmt.Sprintf("https://github.com/%s/%s.git/info/refs?service=git-upload-pack", owner, repo) + req, err := http.NewRequest("GET", githubURL, nil) + if err != nil { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "failed to build request"}) + return + } + req.Header.Set("Authorization", "Basic "+basicAuth("x-access-token", token)) + req.Header.Set("User-Agent", "git/2.0") + + resp, err := uploadPackClient.Do(req) + if err != nil { + utils.Log("UploadPackDiscovery error: %v", err) + c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": "failed to reach GitHub"}) + return + } + defer resp.Body.Close() + + c.Writer.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + c.Writer.WriteHeader(resp.StatusCode) + if _, err := io.Copy(c.Writer, resp.Body); err != nil { + utils.Log("UploadPackDiscovery copy error (status %d): %v", resp.StatusCode, err) + } +} + +func UploadPackHandler(c *gin.Context) { + owner := c.Param("owner") + repo := c.Param("repo") + + token := os.Getenv("GITHUB_TOKEN") + if token == "" { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "GITHUB_TOKEN not set"}) + return + } + + const maxUploadBytes = 50 * 1024 * 1024 // 50 MB + c.Request.Body = http.MaxBytesReader(c.Writer, c.Request.Body, maxUploadBytes) + body, err := io.ReadAll(c.Request.Body) + if err != nil { + if err.Error() == "http: request body too large" { + c.AbortWithStatusJSON(http.StatusRequestEntityTooLarge, gin.H{"error": "request body too large"}) + return + } + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "failed to read body"}) + return + } + + githubURL := fmt.Sprintf("https://github.com/%s/%s.git/git-upload-pack", owner, repo) + req, err := http.NewRequest("POST", githubURL, bytes.NewReader(body)) + if err != nil { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "failed to build request"}) + return + } + req.Header.Set("Authorization", "Basic "+basicAuth("x-access-token", token)) + req.Header.Set("Content-Type", "application/x-git-upload-pack-request") + req.Header.Set("User-Agent", "git/2.0") + + resp, err := uploadPackClient.Do(req) + if err != nil { + utils.Log("UploadPack error: %v", err) + c.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": "failed to reach GitHub"}) + return + } + defer resp.Body.Close() + + c.Writer.Header().Set("Content-Type", "application/x-git-upload-pack-result") + c.Writer.WriteHeader(resp.StatusCode) + if _, err := io.Copy(c.Writer, resp.Body); err != nil { + utils.Log("UploadPack copy error: %v", err) + } +} + +func basicAuth(username, password string) string { + credentials := username + ":" + password + return base64.StdEncoding.EncodeToString([]byte(credentials)) +} + // sendErrorResponse envía una respuesta de error en formato Git protocol func sendErrorResponse(c *gin.Context, errorMsg string) { c.Writer.Header().Set("Content-Type", "application/x-git-receive-pack-result") diff --git a/internal/http/handlers_upload_test.go b/internal/http/handlers_upload_test.go new file mode 100644 index 0000000..a25e8e5 --- /dev/null +++ b/internal/http/handlers_upload_test.go @@ -0,0 +1,240 @@ +package http + +import ( + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "testing" + + "github.com/gin-gonic/gin" +) + +// mockTransport redirige peticiones a github.com al mockURL dado. +type mockTransport struct { + mockURL string + base http.RoundTripper +} + +func (t *mockTransport) RoundTrip(req *http.Request) (*http.Response, error) { + if strings.Contains(req.URL.Host, "github.com") { + mock, _ := url.Parse(t.mockURL) + req = req.Clone(req.Context()) + req.URL.Scheme = mock.Scheme + req.URL.Host = mock.Host + } + return t.base.RoundTrip(req) +} + +// TestBasicAuth verifica que basicAuth codifique correctamente en base64 +func TestBasicAuth(t *testing.T) { + result := basicAuth("x-access-token", "mytoken") + // "x-access-token:mytoken" en base64 = "eC1hY2Nlc3MtdG9rZW46bXl0b2tlbg==" + expected := "eC1hY2Nlc3MtdG9rZW46bXl0b2tlbg==" + if result != expected { + t.Errorf("basicAuth() = %q; want %q", result, expected) + } +} + +func TestBasicAuth_EmptyPassword(t *testing.T) { + result := basicAuth("user", "") + if result == "" { + t.Error("basicAuth() should not return empty string") + } +} + +// TestUploadPackDiscoveryHandler_NoToken verifica rechazo sin GITHUB_TOKEN +func TestUploadPackDiscoveryHandler_NoToken(t *testing.T) { + t.Setenv("GITHUB_TOKEN", "") + + gin.SetMode(gin.TestMode) + r := gin.New() + r.GET("/info/refs", UploadPackDiscoveryHandler) + + req, _ := http.NewRequest("GET", "/info/refs?service=git-upload-pack", nil) + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + + if w.Code != http.StatusInternalServerError { + t.Errorf("Expected 500 when GITHUB_TOKEN not set, got %d", w.Code) + } + + var body map[string]string + if err := json.NewDecoder(w.Body).Decode(&body); err != nil { + t.Fatalf("Failed to decode response: %v", err) + } + if body["error"] != "GITHUB_TOKEN not set" { + t.Errorf("Expected error 'GITHUB_TOKEN not set', got %q", body["error"]) + } +} + +// TestUploadPackHandler_NoToken verifica rechazo sin GITHUB_TOKEN +func TestUploadPackHandler_NoToken(t *testing.T) { + t.Setenv("GITHUB_TOKEN", "") + + gin.SetMode(gin.TestMode) + r := gin.New() + r.POST("/git-upload-pack", UploadPackHandler) + + req, _ := http.NewRequest("POST", "/git-upload-pack", strings.NewReader("")) + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + + if w.Code != http.StatusInternalServerError { + t.Errorf("Expected 500 when GITHUB_TOKEN not set, got %d", w.Code) + } + + var body map[string]string + if err := json.NewDecoder(w.Body).Decode(&body); err != nil { + t.Fatalf("Failed to decode response: %v", err) + } + if body["error"] != "GITHUB_TOKEN not set" { + t.Errorf("Expected error 'GITHUB_TOKEN not set', got %q", body["error"]) + } +} + +// TestUploadPackDiscoveryHandler_ProxiesGitHub verifica que el handler haga proxy correcto +func TestUploadPackDiscoveryHandler_ProxiesGitHub(t *testing.T) { + fakeAdvertisement := "001e# service=git-upload-pack\n00000032abc123 refs/heads/main\n0000" + + // Mock del servidor de GitHub + mockGitHub := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Verificar que llega con Authorization + auth := r.Header.Get("Authorization") + if !strings.HasPrefix(auth, "Basic ") { + t.Errorf("Expected Basic auth header, got %q", auth) + } + // Verificar User-Agent + if r.Header.Get("User-Agent") != "git/2.0" { + t.Errorf("Expected User-Agent git/2.0, got %q", r.Header.Get("User-Agent")) + } + w.Header().Set("Content-Type", "application/x-git-upload-pack-advertisement") + w.WriteHeader(http.StatusOK) + io.WriteString(w, fakeAdvertisement) + })) + defer mockGitHub.Close() + + t.Setenv("GITHUB_TOKEN", "test-token-123") + + // Swappear uploadPackClient para redirigir github.com al mock + origUploadPackClient := uploadPackClient + uploadPackClient = &http.Client{ + Transport: &mockTransport{mockURL: mockGitHub.URL, base: mockGitHub.Client().Transport}, + } + defer func() { uploadPackClient = origUploadPackClient }() + + gin.SetMode(gin.TestMode) + r := gin.New() + r.GET("/:owner/:repo/info/refs", UploadPackDiscoveryHandler) + + req, _ := http.NewRequest("GET", "/owner/repo/info/refs?service=git-upload-pack", nil) + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + + if w.Code != http.StatusOK { + t.Errorf("Expected 200, got %d", w.Code) + } + if ct := w.Header().Get("Content-Type"); ct != "application/x-git-upload-pack-advertisement" { + t.Errorf("Expected Content-Type application/x-git-upload-pack-advertisement, got %q", ct) + } + if w.Body.String() != fakeAdvertisement { + t.Errorf("Expected proxied body %q, got %q", fakeAdvertisement, w.Body.String()) + } +} + +// TestUploadPackHandler_ProxiesGitHub verifica que el POST /git-upload-pack haga proxy correcto +func TestUploadPackHandler_ProxiesGitHub(t *testing.T) { + fakePackData := "0008NAK\n" + receivedBody := "" + + mockGitHub := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Verificar método y Content-Type + if r.Method != "POST" { + t.Errorf("Expected POST, got %s", r.Method) + } + if r.Header.Get("Content-Type") != "application/x-git-upload-pack-request" { + t.Errorf("Expected upload-pack Content-Type, got %q", r.Header.Get("Content-Type")) + } + bodyBytes, _ := io.ReadAll(r.Body) + receivedBody = string(bodyBytes) + + w.Header().Set("Content-Type", "application/x-git-upload-pack-result") + w.WriteHeader(http.StatusOK) + io.WriteString(w, fakePackData) + })) + defer mockGitHub.Close() + + t.Setenv("GITHUB_TOKEN", "test-token-456") + + // Swappear uploadPackClient para redirigir github.com al mock + origUploadPackClient := uploadPackClient + uploadPackClient = &http.Client{ + Transport: &mockTransport{mockURL: mockGitHub.URL, base: mockGitHub.Client().Transport}, + } + defer func() { uploadPackClient = origUploadPackClient }() + + gin.SetMode(gin.TestMode) + r := gin.New() + r.POST("/:owner/:repo/git-upload-pack", UploadPackHandler) + + requestBody := "0011want abc123\n0000" + req, _ := http.NewRequest("POST", "/owner/repo/git-upload-pack", strings.NewReader(requestBody)) + req.Header.Set("Content-Type", "application/x-git-upload-pack-request") + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + + if w.Code != http.StatusOK { + t.Errorf("Expected 200, got %d", w.Code) + } + if w.Body.String() != fakePackData { + t.Errorf("Expected proxied pack data %q, got %q", fakePackData, w.Body.String()) + } + if receivedBody != requestBody { + t.Errorf("Mock GitHub received wrong body: got %q, want %q", receivedBody, requestBody) + } +} + +// TestInfoRefsRouter_UploadPack verifica que el router enrute git-upload-pack correctamente +func TestInfoRefsRouter_UploadPack(t *testing.T) { + t.Setenv("GITHUB_TOKEN", "") + + gin.SetMode(gin.TestMode) + r := gin.New() + r.GET("/:owner/:repo/info/refs", func(c *gin.Context) { + service := c.Query("service") + if service == "git-receive-pack" { + c.String(http.StatusOK, "receive-pack") + } else if service == "git-upload-pack" { + // Sin token → 500, pero el routing llegó aquí + c.String(http.StatusInternalServerError, "upload-pack-reached") + } else { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "Unsupported service"}) + } + }) + + // git-upload-pack debe llegar al handler correcto + req, _ := http.NewRequest("GET", "/owner/repo/info/refs?service=git-upload-pack", nil) + w := httptest.NewRecorder() + r.ServeHTTP(w, req) + if w.Body.String() != "upload-pack-reached" { + t.Errorf("git-upload-pack should reach upload-pack handler, got %q", w.Body.String()) + } + + // git-receive-pack debe llegar al handler correcto + req, _ = http.NewRequest("GET", "/owner/repo/info/refs?service=git-receive-pack", nil) + w = httptest.NewRecorder() + r.ServeHTTP(w, req) + if w.Body.String() != "receive-pack" { + t.Errorf("git-receive-pack should reach receive-pack handler, got %q", w.Body.String()) + } + + // servicio desconocido debe retornar 400 + req, _ = http.NewRequest("GET", "/owner/repo/info/refs?service=unknown", nil) + w = httptest.NewRecorder() + r.ServeHTTP(w, req) + if w.Code != http.StatusBadRequest { + t.Errorf("Unknown service should return 400, got %d", w.Code) + } +} diff --git a/internal/http/router.go b/internal/http/router.go index fee1138..0a73fb8 100644 --- a/internal/http/router.go +++ b/internal/http/router.go @@ -124,14 +124,19 @@ func SetupRouter(cfg *config.Config) *gin.Engine { service := c.Query("service") if service == "git-receive-pack" { ReceivePackDiscoveryHandler(c) + } else if service == "git-upload-pack" { + UploadPackDiscoveryHandler(c) } else { - c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "Only git-receive-pack is supported"}) + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "Unsupported service"}) } }) // Git Smart HTTP - receive-pack (push) gh.POST("/:owner/:repo/git-receive-pack", ReceivePackHandler) + // Git Smart HTTP - upload-pack (fetch/pull) + gh.POST("/:owner/:repo/git-upload-pack", UploadPackHandler) + // Issues y comentarios anónimos gh.POST("/:owner/:repo/issues/anonymous", CreateAnonymousIssueHandler) gh.POST("/:owner/:repo/issues/:number/comments/anonymous", CreateAnonymousCommentHandler) diff --git a/web/index.html b/web/index.html index e138272..c26e9b3 100644 --- a/web/index.html +++ b/web/index.html @@ -30,6 +30,9 @@ :root { --bg: #0d1117; --fg: #c9d1d9; + --fg-secondary: #8b949e; + --bg-secondary: #161b22; + --bg-hover: #1f2937; --accent: #ffa657; --accent-dark: #f0883e; --border: #30363d; @@ -51,15 +54,18 @@ } :root[data-theme="light"] { - --bg: #ffffff; - --fg: #24292f; - --accent: #d16014; - --accent-dark: #b84f0f; - --border: #d0d7de; - --card: #f6f8fa; - --code-bg: #f6f8fa; - --shadow: rgba(0, 0, 0, 0.1); - --shadow-hover: rgba(0, 0, 0, 0.15); + --bg: #f4f5f7; + --fg: #1a1f2e; + --fg-secondary: #5c6370; + --bg-secondary: #eef0f3; + --bg-hover: #e8eaed; + --accent: #c05c10; + --accent-dark: #a34d0d; + --border: #dde1e7; + --card: #ffffff; + --code-bg: #f0f2f5; + --shadow: rgba(0, 0, 0, 0.07); + --shadow-hover: rgba(0, 0, 0, 0.12); --radius-lg: 16px; --radius-md: 12px; --radius-sm: 8px; @@ -68,22 +74,25 @@ --issue-shell-border: var(--border); --issue-form-bg: var(--card); --issue-form-border: var(--border); - --issue-input-bg: #ffffff; - --issue-input-border: var(--border); - --issue-gradient-overlay: rgba(209, 96, 20, 0.05); + --issue-input-bg: #f8f9fb; + --issue-input-border: #cdd1d9; + --issue-gradient-overlay: rgba(192, 92, 16, 0.04); } @media (prefers-color-scheme: light) { :root:not([data-theme]) { - --bg: #ffffff; - --fg: #24292f; - --accent: #d16014; - --accent-dark: #b84f0f; - --border: #d0d7de; - --card: #f6f8fa; - --code-bg: #f6f8fa; - --shadow: rgba(0, 0, 0, 0.1); - --shadow-hover: rgba(0, 0, 0, 0.15); + --bg: #f4f5f7; + --fg: #1a1f2e; + --fg-secondary: #5c6370; + --bg-secondary: #eef0f3; + --bg-hover: #e8eaed; + --accent: #c05c10; + --accent-dark: #a34d0d; + --border: #dde1e7; + --card: #ffffff; + --code-bg: #f0f2f5; + --shadow: rgba(0, 0, 0, 0.07); + --shadow-hover: rgba(0, 0, 0, 0.12); --radius-lg: 16px; --radius-md: 12px; --radius-sm: 8px; @@ -92,9 +101,9 @@ --issue-shell-border: var(--border); --issue-form-bg: var(--card); --issue-form-border: var(--border); - --issue-input-bg: #ffffff; - --issue-input-border: var(--border); - --issue-gradient-overlay: rgba(209, 96, 20, 0.05); + --issue-input-bg: #f8f9fb; + --issue-input-border: #cdd1d9; + --issue-gradient-overlay: rgba(192, 92, 16, 0.04); } } @@ -118,41 +127,32 @@ top: 1.5rem; right: 1.5rem; z-index: 1000; - background: var(--card); - border: 1px solid var(--border); - border-radius: 12px; - padding: 0.5rem; display: flex; - gap: 0.25rem; - box-shadow: 0 4px 12px var(--shadow); - transition: all 0.3s ease; - } - .theme-toggle:hover { - box-shadow: 0 6px 16px var(--shadow-hover); + gap: 0.5rem; + align-items: center; } .theme-btn { - background: transparent; - border: none; - color: var(--fg); + background: var(--card); + border: 1px solid var(--border); + border-radius: 50%; + width: 40px; + height: 40px; cursor: pointer; - padding: 0.5rem 0.75rem; - border-radius: 8px; - font-size: 1.1rem; - transition: all 0.2s ease; - opacity: 0.6; display: flex; align-items: center; justify-content: center; - min-width: 36px; + box-shadow: 0 2px 8px var(--shadow); + transition: box-shadow 0.2s ease, transform 0.15s ease; + padding: 0; + font-size: 1rem; + color: var(--fg); } .theme-btn:hover { - opacity: 1; - background: var(--bg); + box-shadow: 0 4px 14px var(--shadow-hover); + transform: scale(1.08); } - .theme-btn.active { - opacity: 1; - background: var(--accent); - color: #fff; + .theme-btn:active { + transform: scale(0.95); } header { text-align: center; margin-bottom: 3rem; } @@ -289,21 +289,71 @@ } .terminal { - background: var(--code-bg); - border: 1px solid var(--border); + background: #1a1b26; + border: 1px solid #2d2f3f; border-radius: var(--radius-md); - padding: 1.5rem; font-family: 'IBM Plex Mono', monospace; - font-size: clamp(0.9rem, 2.5vw, 1rem); + font-size: clamp(0.85rem, 2.5vw, 0.95rem); overflow-x: auto; margin: 2rem 0; - box-shadow: 0 8px 32px var(--shadow); - white-space: pre; + box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); transition: all 0.3s ease; } - .terminal .comment { color: #5c98ff; } - .terminal .prompt { color: #79c0ff; } - .terminal .success { color: #7ee787; } + .terminal-tabs { + display: flex; + gap: 0.5rem; + margin-bottom: 0.75rem; + } + .terminal-tab { + padding: 0.4rem 1rem; + border: 1px solid var(--border); + border-radius: var(--radius-pill); + background: transparent; + color: var(--fg-secondary); + font-family: 'IBM Plex Mono', monospace; + font-size: 0.82rem; + cursor: pointer; + transition: all 0.2s ease; + } + .terminal-tab:hover { + color: var(--fg); + border-color: var(--fg-secondary); + } + .terminal-tab.active { + background: #1a1b26; + color: #a9b1d6; + border-color: #2d2f3f; + } + + .terminal-titlebar { + height: 40px; + background: #252636; + border-bottom: 1px solid #2d2f3f; + border-radius: var(--radius-md) var(--radius-md) 0 0; + display: flex; + align-items: center; + padding: 0 16px; + gap: 8px; + flex-shrink: 0; + } + .terminal-btn { + width: 12px; + height: 12px; + border-radius: 50%; + flex-shrink: 0; + } + .terminal-btn.close { background: #ff5f57; } + .terminal-btn.min { background: #febc2e; } + .terminal-btn.max { background: #28c840; } + .terminal-body { + padding: 1.25rem 1.5rem; + white-space: pre; + color: #a9b1d6; + line-height: 1.7; + } + .terminal .comment { color: #565f89; } + .terminal .prompt { color: #7aa2f7; font-weight: 600; } + .terminal .success { color: #9ece6a; } .grid { display: grid; @@ -443,7 +493,6 @@ font-weight: 700; font-size: 15px; cursor: pointer; - box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); } .badge-generator button { font-family: 'IBM Plex Mono', monospace; @@ -475,154 +524,70 @@ border-radius: var(--radius-sm); } - /* Forms for anonymous issues */ - .issue-section { - position: relative; - background: linear-gradient(145deg, rgba(255,166,87,0.14), rgba(255,107,107,0.12)); - border: 1px solid rgba(255,166,87,0.45); - border-radius: var(--radius-lg); - padding: 2.5px; - margin: 3rem 0; - box-shadow: 0 16px 38px var(--shadow); - transition: all 0.3s ease; - } - .issue-shell { - background: var(--issue-shell-bg); - backdrop-filter: blur(12px); - border-radius: var(--radius-lg); - padding: 2rem; - display: grid; - gap: 1.35rem; - border: 1px solid var(--issue-shell-border); - transition: all 0.3s ease; - } - .issue-header { - display: grid; - gap: .4rem; - } - .issue-eyebrow { - display: inline-flex; - align-items: center; - gap: .4rem; - padding: .35rem .75rem; - background: var(--issue-gradient-overlay); - color: var(--accent); - border: 1px solid var(--accent); - border-radius: var(--radius-pill); - font-family: 'IBM Plex Mono', monospace; - font-size: .85rem; - width: fit-content; - transition: all 0.3s ease; - } - .issue-sub { - opacity: .8; - max-width: 620px; - } - .issue-grid { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); - gap: 1.1rem; + /* Light mode overrides for issue section */ + :root[data-theme="light"] .issue-container { + box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06), 0 0 0 1px var(--border); } - .issue-form { - position: relative; - overflow: hidden; - display: grid; - gap: .85rem; - background: radial-gradient(circle at 20% 20%, var(--issue-gradient-overlay), transparent 45%), var(--issue-form-bg); - border: 1px solid var(--issue-form-border); - border-radius: var(--radius-lg); - padding: 1.35rem 1.35rem; - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 28px var(--shadow); - transition: all 0.3s ease; + :root[data-theme="light"] .form-group input, + :root[data-theme="light"] .form-group textarea { + background: #ffffff; + border-color: #c8cdd6; + color: #1a1f2e; } - .issue-form::after { - content: ""; - position: absolute; - inset: 0; - border-radius: inherit; - background: linear-gradient(135deg, var(--issue-gradient-overlay), transparent); - opacity: .4; - pointer-events: none; - transition: opacity 0.3s ease; - } - .issue-form:hover { - transform: translateY(-2px); + :root[data-theme="light"] .form-group input:focus, + :root[data-theme="light"] .form-group textarea:focus { border-color: var(--accent); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 14px 34px var(--shadow-hover); - } - .issue-form h3 { - position: relative; - z-index: 1; - margin: 0 0 .1rem; - color: var(--accent); - letter-spacing: .01em; - } - .issue-form label { - position: relative; - z-index: 1; - font-weight: 700; - opacity: .9; - letter-spacing: .01em; + box-shadow: 0 0 0 3px rgba(192, 92, 16, 0.1); } - .issue-form input, .issue-form textarea { - position: relative; - z-index: 1; - background: var(--issue-input-bg); - border: 1px solid var(--issue-input-border); - border-radius: var(--radius-sm); - padding: .85rem 1rem; - color: var(--fg); - font-family: 'IBM Plex Mono', monospace; - transition: border-color .18s ease, box-shadow .18s ease, transform .12s ease, background-color 0.3s ease; + :root[data-theme="light"] .form-note { + background: #f0f2f5; + border-color: #dde1e7; } - .issue-form input:focus, .issue-form textarea:focus { - outline: none; - border-color: var(--accent); - box-shadow: 0 0 0 3px var(--issue-gradient-overlay); - transform: translateY(-1px); + :root[data-theme="light"] .issue-tabs { + border-bottom-color: #dde1e7; } - .issue-form textarea { min-height: 150px; resize: vertical; } - .issue-actions { - display: flex; - gap: .6rem; - flex-wrap: wrap; - align-items: center; + :root[data-theme="light"] .issue-tab.active { + font-weight: 600; } - .issue-status { - font-family: 'IBM Plex Mono', monospace; - font-size: .9rem; - opacity: .8; + :root[data-theme="light"] .md-editor { + background: #ffffff; + border-color: #c8cdd6; } - .issue-note { - font-size: .9rem; - opacity: .85; - margin-top: .4rem; + :root[data-theme="light"] .md-tabs { + border-bottom-color: #dde1e7; + background: #f4f5f7; } - .issue-note a, - .issue-sub a { - color: var(--accent); + @media (prefers-color-scheme: light) { + :root:not([data-theme]) .form-group input, + :root:not([data-theme]) .form-group textarea { + background: #ffffff; + border-color: #c8cdd6; + color: #1a1f2e; + } + :root:not([data-theme]) .form-group input:focus, + :root:not([data-theme]) .form-group textarea:focus { + border-color: var(--accent); + box-shadow: 0 0 0 3px rgba(192, 92, 16, 0.1); + } + :root:not([data-theme]) .form-note { + background: #f0f2f5; + border-color: #dde1e7; + } + :root:not([data-theme]) .md-editor { + background: #ffffff; + border-color: #c8cdd6; + } + :root:not([data-theme]) .md-tabs { + border-bottom-color: #dde1e7; + background: #f4f5f7; + } } - /* Light theme tuning for issues */ - :root[data-theme="light"] .issue-section { - background: linear-gradient(145deg, rgba(209,96,20,0.06), rgba(255,107,107,0.06)); - border: 1px solid var(--border); - box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12); - } - :root[data-theme="light"] .issue-shell { - background: var(--card); - border: 1px solid var(--border); - backdrop-filter: none; - } - :root[data-theme="light"] .issue-form { - background: radial-gradient(circle at 20% 20%, var(--issue-gradient-overlay), transparent 45%), var(--issue-form-bg); - border: 1px solid var(--border); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 26px rgba(0, 0, 0, 0.12); - } - :root[data-theme="light"] .issue-form:hover { - border-color: var(--accent); - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 12px 30px rgba(0, 0, 0, 0.16); - } + /* Forms for anonymous issues - legacy classes kept for compatibility */ + .issue-shell { display: none; } + .issue-grid { display: none; } + .issue-note { font-size: .9rem; opacity: .85; margin-top: .4rem; } + .issue-note a { color: var(--accent); } .snippet { background: var(--code-bg); border: 1px solid var(--border); @@ -671,11 +636,281 @@ } .footer a { color: var(--accent); text-decoration: none; } + /* Redesigned Anonymous Issues Section */ + .issue-section { + margin: 4rem 0; + } + .issue-container { + width: 100%; + background: var(--card); + border: 1px solid var(--border); + border-radius: var(--radius-lg); + padding: 2rem 2.5rem; + box-shadow: 0 4px 20px var(--shadow); + } + .issue-header { + text-align: center; + margin-bottom: 2rem; + } + .issue-eyebrow { + color: var(--accent); + font-size: 0.875rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.05em; + margin-bottom: 0.5rem; + } + .issue-header h2 { + margin: 0 0 0.5rem; + font-size: 1.5rem; + font-weight: 700; + } + .issue-header p { + color: var(--fg-secondary); + margin: 0; + font-size: 0.95rem; + line-height: 1.5; + } + .issue-tabs { + display: flex; + border-bottom: 1px solid var(--border); + margin-bottom: 2rem; + } + .issue-tab { + flex: 1; + padding: 0.75rem 1rem; + border: none; + background: transparent; + color: var(--fg-secondary); + font-size: 0.95rem; + font-weight: 500; + cursor: pointer; + transition: all 0.2s ease; + } + .issue-tab:hover { + color: var(--fg); + background: var(--bg-hover); + } + .issue-tab.active { + color: var(--accent); + border-bottom-color: var(--accent); + } + .issue-form-container { + position: relative; + } + .issue-form { + display: none; + animation: fadeIn 0.3s ease; + } + .issue-form.active { + display: block; + } + @keyframes fadeIn { + from { opacity: 0; transform: translateY(10px); } + to { opacity: 1; transform: translateY(0); } + } + .repo-input-group { + display: flex; + align-items: center; + gap: 0.5rem; + } + .repo-separator { + color: var(--fg-secondary); + font-weight: 500; + } + .repo-input-group input { + flex: 1; + } + .form-group { + margin-bottom: 1.5rem; + } + .form-group label { + display: block; + margin-bottom: 0.5rem; + font-weight: 500; + color: var(--fg); + font-size: 0.9rem; + } + .form-group input, + .form-group textarea { + width: 100%; + padding: 0.75rem; + border: 1px solid var(--border); + border-radius: var(--radius-sm); + background: var(--bg); + color: var(--fg); + font-family: inherit; + font-size: 0.95rem; + transition: border-color 0.2s ease; + } + .form-group input:focus, + .form-group textarea:focus { + outline: none; + border-color: var(--accent); + } + .form-group textarea { + min-height: 120px; + resize: vertical; + } + .form-actions { + display: flex; + align-items: center; + gap: 1rem; + margin-bottom: 1rem; + } + .form-status { + font-size: 0.875rem; + font-weight: 500; + color: var(--fg-secondary); + } + .form-note { + background: var(--bg-secondary); + border: 1px solid var(--border); + border-radius: var(--radius-sm); + padding: 1rem; + margin-bottom: 1rem; + } + .form-note p { + margin: 0 0 0.5rem; + font-size: 0.875rem; + color: var(--fg-secondary); + } + .form-note p:last-child { + margin-bottom: 0; + } + .form-result { + font-size: 0.875rem; + color: var(--accent); + font-weight: 500; + } + + /* Redesigned Badge Section */ + .badge-section { + margin: 4rem 0; + } + .badge-container { + max-width: 700px; + margin: 0 auto; + } + .badge-header { + text-align: center; + margin-bottom: 2rem; + } + .badge-eyebrow { + color: var(--accent); + font-size: 0.875rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.05em; + margin-bottom: 0.5rem; + } + .badge-header h3 { + margin: 0 0 0.5rem; + font-size: 1.5rem; + font-weight: 700; + } + .badge-header p { + color: var(--fg-secondary); + margin: 0; + font-size: 0.95rem; + line-height: 1.5; + } + .badge-showcase { + margin-bottom: 2rem; + } + .badge-preview-card { + background: var(--card); + border: 1px solid var(--border); + border-radius: var(--radius-lg); + padding: 1.5rem; + text-align: center; + box-shadow: 0 2px 12px var(--shadow); + } + .badge-static { + margin-bottom: 1rem; + } + .badge-code { + font-family: 'IBM Plex Mono', monospace; + font-size: 0.8rem; + color: var(--fg-secondary); + background: var(--code-bg); + padding: 0.5rem; + border-radius: var(--radius-sm); + border: 1px solid var(--border); + } + .badge-generator { + background: var(--card); + border: 1px solid var(--border); + border-radius: var(--radius-lg); + padding: 2rem; + box-shadow: 0 2px 12px var(--shadow); + } + .badge-generator h4 { + margin: 0 0 0.5rem; + font-size: 1.2rem; + font-weight: 600; + } + .badge-generator p { + color: var(--fg-secondary); + margin: 0 0 1.5rem; + font-size: 0.9rem; + line-height: 1.5; + } + .badge-form { + margin-bottom: 1.5rem; + } + .badge-result { + margin-bottom: 1rem; + font-size: 0.9rem; + } + .badge-result p { + margin: 0; + color: var(--fg-secondary); + } + .badge-copy-section { + background: var(--bg-secondary); + border: 1px solid var(--border); + border-radius: var(--radius-sm); + padding: 1rem; + } + .badge-generated { + text-align: center; + margin-bottom: 1rem; + } + .badge-copy-row { + display: grid; + grid-template-columns: 1fr auto; + gap: 0.5rem; + align-items: center; + } + .badge-copy-row input { + padding: 0.5rem; + border: 1px solid var(--border); + border-radius: var(--radius-sm); + background: var(--bg); + color: var(--fg); + font-family: 'IBM Plex Mono', monospace; + font-size: 0.8rem; + } + .badge-copy-row button { + padding: 0.5rem; + border: 1px solid var(--border); + border-radius: var(--radius-sm); + background: var(--card); + color: var(--fg); + cursor: pointer; + transition: all 0.2s ease; + } + .badge-copy-row button:hover { + background: var(--accent); + color: white; + } + @media (max-width: 768px) { body { padding: 1.5rem .8rem; } main { max-width: 100%; } - .theme-toggle { top: 1rem; right: 1rem; padding: 0.4rem; } - .theme-btn { padding: 0.4rem 0.6rem; font-size: 1rem; min-width: 32px; } + .theme-toggle { top: 1rem; right: 1rem; } + .theme-btn { width: 36px; height: 36px; font-size: 0.95rem; } header { margin-bottom: 2rem; } nav { gap: 1.2rem; font-size: .95rem; flex-direction: column; align-items: center; } .badges { gap: .4rem; } @@ -683,7 +918,8 @@ .stats-banner { padding: 1.5rem; margin: 1.5rem 0 2rem; } .stats-number { font-size: clamp(2.5rem, 8vw, 4rem); } .stats-label { font-size: 1rem; } - .terminal { padding: 1rem; font-size: clamp(0.8rem, 2vw, 0.95rem); } + .terminal { font-size: clamp(0.8rem, 2vw, 0.95rem); } + .terminal-body { padding: 1rem; } .grid { gap: 1rem; } .card { padding: 1.5rem; } .card h3 { font-size: 1.1rem; } @@ -697,10 +933,12 @@ @media (max-width: 480px) { body { padding: 1rem .6rem; } .theme-toggle { top: 0.75rem; right: 0.75rem; } + .theme-btn { width: 34px; height: 34px; } nav { gap: 1rem; font-size: .9rem; } .badges { justify-content: center; } .stats-banner { padding: 1rem; } - .terminal { padding: 0.8rem; } + .terminal { font-size: 0.82rem; } + .terminal-body { padding: 0.75rem; } .grid { grid-template-columns: 1fr; gap: 1rem; } .card { padding: 1.2rem; } .pr-item { padding: 0.6rem; } @@ -709,10 +947,11 @@ -
- - - +
+ + + +
@@ -726,17 +965,12 @@

gitGost

-
-
-# Add as remote → push → done. Fully anonymous. +
+ + +
+
# Add as remote → push → done. Fully anonymous. $ git remote add gost https://gitgost.leapcell.app/v1/gh/torvalds/linux $ git checkout -b fix-typo $ git commit -am "fix: typo in documentation @@ -744,7 +978,15 @@

gitGost

This commit fixes a grammatical error in the README. The word 'recieve' should be 'receive'." $ git push gost fix-typo:main -→ Anonymized commit + PR opened as @gitgost-anonymous +→ Anonymized commit + PR opened as @gitgost-anonymous
+
+ @@ -786,6 +1028,10 @@

Battle-tested Security

Anonymous issues & comments

Open issues and comment on any repo without revealing identity. Each message carries a stable anonymous hash.

+
+

Fetch & Pull Support

+

Clone, fetch, and pull from any GitHub repo through gitGost. Read code anonymously — no account, no trace.

+
@@ -812,95 +1058,147 @@

Sometimes you just want to be a ghost

Anonymous Issues

-
+
Anonymous issues + comments
-
Create issues or comment without exposing your identity. We only keep what’s essential: URL, anonymous hash, and karma.
+

Create issues or comment without exposing your identity. We only keep what’s essential: URL, anonymous hash, and karma.

-
-
-
-

Create anonymous issue

-
- If you haven't already, would you mind reading our approach to comments and guidelines? + +
+ + +
+ +
+
+
+ +
+ + / +
- - - - +
+ +
- + +
+ +
- +
+
+ +
- -
- -
+ +
+ +
+ +
+
+ +
+

Before creating, please read our approach to comments and guidelines.

+

Do not include personal data. We only keep URL + anonymous hash.

+
+
+ + +
+
+ +
+ + / +
-
Do not include personal data. We only keep URL + anonymous hash.
-
-
-
-
-

Post anonymous comment

- - - - - + +
+ - - - +
+ +
+ + +
+ +
+
- +
-
- -
-
-
-
Comments include a footer: anonymous hash + karma + report link.
-
+ +
+ +
+
+ +
+

Comments include a footer with your anonymous hash and karma.

+
+
+

Anonymous Contributor Friendly Badge

-
-
-
-
-

Welcome anonymous contributions

-

Make it visible that your repository accepts PRs via gitGost. Use the static badge or generate a dynamic one for verified repos (.gitgost.yml).

-
- Anonymous Contributor Friendly +
+
+
+
Show your support
+

Welcome anonymous contributions

+

Make it visible that your repository accepts PRs via gitGost. Add our badge to your README.

+
+ +
+
+
+ Anonymous Contributor Friendly
- ![Anonymous Contributor Friendly](https://gitgost.leapcell.app/badges/anonymous-friendly.svg) + ![Anonymous Contributor Friendly](https://gitgost.leapcell.app/badges/anonymous-friendly.svg) +
+
+
+ +
+

Get a dynamic badge

+

Add a .gitgost.yml file to your repo root to enable verification and get a dynamic badge that shows your acceptance of anonymous contributions.

+ +
+
+ +
+
-
- - - -
-