model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT Package model holds the domain types shared across the GitHub commit-query tool. It is a leaf package with no internal dependencies so both the GitHub client and the renderers can depend on it without creating import cycles.

Index

Constants

View Source
const SchemaVersion = "sting.skaphos.io/v1"

SchemaVersion identifies the sting Result contract. It is emitted on every Result so downstream consumers (e.g. a Wake evidence adapter) can pin the shape they map from and detect drift. Bump it on any breaking change to Result or Commit.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commit

type Commit struct {
	SHA        string    `json:"sha"`
	Repo       string    `json:"repo"`             // "owner/repo"
	Author     string    `json:"author,omitempty"` // GitHub login, if known
	AuthorName string    `json:"author_name"`      // git author name
	Email      string    `json:"email,omitempty"`  // git author email
	Date       time.Time `json:"date"`             // git author date
	Message    string    `json:"message"`          // full commit message
	URL        string    `json:"url"`              // html_url
	Additions  int       `json:"additions,omitempty"`
	Deletions  int       `json:"deletions,omitempty"`
}

Commit is a normalized commit record independent of the GitHub API shape.

func (Commit) Summary

func (c Commit) Summary() string

Summary is the first line of the commit message.

type Query

type Query struct {
	// Author is the GitHub login (or, for search, may be an email) whose
	// commits are wanted.
	Author string
	// Since and Until bound the commit author date, inclusive. A zero Until
	// means "now".
	Since time.Time
	Until time.Time
	// Scope selects the discovery strategy.
	Scope Scope
	// Repos is the list of "owner/repo" targets for ScopeRepos.
	Repos []string
	// Org is the organization login for ScopeOrg.
	Org string
	// IncludeStats requests per-commit additions/deletions. This costs one
	// extra API call per commit, so it is off by default.
	IncludeStats bool
	// MaxCommits caps the number of commits returned (0 = no cap).
	MaxCommits int
}

Query describes a single commit-retrieval request.

type Result

type Result struct {
	// SchemaVersion pins the Result contract (see the package SchemaVersion
	// constant). GeneratedAt records when the query ran, giving the result
	// evidence-style provenance.
	SchemaVersion string    `json:"schema_version"`
	GeneratedAt   time.Time `json:"generated_at"`
	Author        string    `json:"author"`
	Scope         Scope     `json:"scope"`
	Since         time.Time `json:"since"`
	Until         time.Time `json:"until"`
	Count         int       `json:"count"`
	Commits       []Commit  `json:"commits"`
	Truncated     bool      `json:"truncated,omitempty"` // true if MaxCommits clipped results
}

Result is the outcome of a Query: the matching commits plus the parameters that produced them, suitable for direct serialization.

type Scope

type Scope string

Scope selects how commits are discovered for an author.

const (
	// ScopeSearch uses GitHub's global commit search index (author across all
	// indexed public repositories). Broad but limited to indexed/public repos.
	ScopeSearch Scope = "search"
	// ScopeRepos lists commits within an explicit set of "owner/repo" targets.
	ScopeRepos Scope = "repos"
	// ScopeOrg enumerates an organization's repositories and lists commits in each.
	ScopeOrg Scope = "org"
)

func (Scope) Valid

func (s Scope) Valid() bool

Valid reports whether s is a recognized scope.

Jump to

Keyboard shortcuts

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