compare

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package compare holds the Githome web front's branch-comparison handlers: the branch picker that starts a comparison, and the range view that shows the three-dot diff between two branches with an optional pull-request creation form. It mirrors the repo and pulls packages: each handler loads the repository through its Resolve middleware, maps domain data into fe/view models through fe/route, and renders through fe/render. See implementation/09 section 8.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Repos  *domain.RepoService
	Render *render.Set
	View   *view.Builder
	Logger *slog.Logger
}

Deps are the compare handlers' dependencies.

type Handlers

type Handlers struct {
	// contains filtered or unexported fields
}

Handlers is the compare handler set. One is built at boot and shared; it holds no per-request state.

func New

func New(d Deps) *Handlers

New wires the handler set from its dependencies.

func (*Handlers) Picker

func (h *Handlers) Picker(c *mizu.Ctx) error

Picker renders the branch-picker page, GET /{owner}/{repo}/compare. When the form is submitted with base and head query params it redirects immediately to the compare range URL, so the no-JS path does not need a separate POST. An empty or uninitialized repository shows a blankslate. See implementation/09 section 8.

func (*Handlers) Range

func (h *Handlers) Range(c *mizu.Ctx) error

Range renders the comparison between two branches, GET /{owner}/{repo}/compare/{basehead...}. The basehead tail is parsed as "base...head" (the merge-base diff) or "base..head" (the direct diff), with each side optionally qualified as owner:ref or owner:repo:ref. With ?expand=1 the PR creation form is shown below the diff. A missing branch, a basehead that does not parse, or a qualified side naming another repository renders the soft 404. See implementation/09 section 8.

func (*Handlers) Resolve

func (h *Handlers) Resolve(next mizu.Handler) mizu.Handler

Resolve loads the repository named by the {owner} and {repo} path parameters, read-gated for the viewer, and stores it on the context. A missing or private repository renders the same 404 to avoid confirming its existence.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL