git-stats – zgo.at/git-stats Index | Files | Directories

package gitstats

import "zgo.at/git-stats"

Index

Variables

var DBFiles embed.FS
var TplFiles embed.FS

Functions

func CountCommits

func CountCommits(ctx context.Context, repoID int32, rng ztime.Range) (int, error)

func FindOrInsertAuthor

func FindOrInsertAuthor(ctx context.Context, c Commit, names, emails map[string]int64) (int64, error)

Find author by name or email, or insert if it doesn't exist.

TODO: treat as case-insensitive, now we have:

Eric Anholt <anholt@freebsd.org>, <anholt@FreeBSD.org>
walter harms, Walter Harms <wharms@bfs.de>

And that's not too useful.

func FindOrInsertFile

func FindOrInsertFile(ctx context.Context, c Commit, files map[string]int64) ([]int64, Ints, Ints, error)

Types

type Author

type Author struct {
	ID     int64   `db:"author_id,id"`
	RepoID int32   `db:"repo_id"`
	Names  Strings `db:"names"`
	Emails Strings `db:"emails"`

	Commits int    `db:"-"`
	Added   int    `db:"-"`
	Removed int    `db:"-"`
	First   string `db:"-"`
	Last    string `db:"-"`
}

func (*Author) ByID

func (a *Author) ByID(ctx context.Context, repoID int32, authorID int64) error

type AuthorStat

type AuthorStat struct {
	AuthorID    int       `db:"author_id"`
	Commits     int       `db:"commits"`
	Added       int       `db:"added"`
	Removed     int       `db:"removed"`
	CommitPerc  float32   `db:"commit_perc"`
	AddedPerc   float32   `db:"added_perc"`
	RemovedPerc float32   `db:"removed_perc"`
	Names       Strings   `db:"names"`
	Emails      Strings   `db:"emails"`
	First       time.Time `db:"first"`
	Last        time.Time `db:"last"`

	Domains []string `db:"-"`
}

func (*AuthorStat) ByID

func (s *AuthorStat) ByID(ctx context.Context, repoID int32, authorID int64, rng ztime.Range) error

type AuthorStats

type AuthorStats []AuthorStat

func (AuthorStats) Domains

func (s AuthorStats) Domains() []Domain

func (*AuthorStats) List

func (s *AuthorStats) List(ctx context.Context, repoID int32, order string, rng ztime.Range) error

type Authors

type Authors []Author

func (*Authors) List

func (a *Authors) List(ctx context.Context, repoID int32) error

type Commit

type Commit struct {
	RepoID     int32        `db:"repo_id"`
	Hash       Hash         `db:"hash,id"`
	Date       time.Time    `db:"date"`
	AuthorID   int          `db:"author_id"`
	Exclude    sql.NullBool `db:"exclude"`
	Files      Strings      `db:"files"`
	Added      Ints         `db:"added"`
	Removed    Ints         `db:"removed"`
	AddedSum   int          `db:"added_sum"`
	RemovedSum int          `db:"removed_sum"`
	Subject    string       `db:"subject"`

	Email    string       `db:"-"`
	Name     string       `db:"-"`
	UpdFiles []CommitFile `db:"files"`
}

func (*Commit) ShouldExclude

func (c *Commit) ShouldExclude() bool

Also: toml 782628a7 (gofmt -s)

type CommitFile

type CommitFile struct {
	Path, Added, Removed string
	Exclude              sql.NullBool
}

func (*CommitFile) ShouldExclude

func (c *CommitFile) ShouldExclude() bool

type CommitStat

type CommitStat struct {
	Date    time.Time `db:"date" json:"date"`
	Commits int       `db:"commits" json:"commits"`
	Added   int       `db:"added" json:"added"`
	Removed int       `db:"removed" json:"removed"`
}

type CommitStats

type CommitStats []CommitStat

func (*CommitStats) List

func (s *CommitStats) List(ctx context.Context, repoID int32, rng ztime.Range, authorID int64, groupMonth bool) error

type Commits

type Commits []Commit

func (*Commits) ByAuthor

func (c *Commits) ByAuthor(ctx context.Context, repoID int32, authorID int64, rng ztime.Range) error

type Domain

type Domain struct {
	Domain string
	Count  int
}

type Event

type Event struct {
	EventID int32     `db:"event_id,id" json:"-"`
	RepoID  int32     `db:"repo_id" json:"-"`
	Name    string    `db:"name" json:"name"`
	Date    time.Time `db:"date" json:"date"`
	Kind    EventKind `db:"kind" json:"kind"`
}

func (*Event) Find

func (e *Event) Find(ctx context.Context) error

func (*Event) Insert

func (e *Event) Insert(ctx context.Context) error

type EventKind

type EventKind byte

func (EventKind) String

func (e EventKind) String() string

type Events

type Events []Event

func (*Events) List

func (t *Events) List(ctx context.Context, repoID int32) error

type File

type File struct {
	ID      int64  `db:"file_id,id"`
	RepoID  int    `db:"repo_id"`
	Path    string `db:"path"`
	Exclude bool   `db:"exclude"`
}

type FileStat

type FileStat []struct {
	ID         int    `db:"file_id"`
	Path       string `db:"path"`
	NumCommits string `db:"num_commits"`
}

func (*FileStat) List

func (s *FileStat) List(ctx context.Context, repoID int32) error

TODO: positional: "/foo/bar%" -depth group stuff by max depth Add authors info

type Files

type Files []File

func (*Files) List

func (f *Files) List(ctx context.Context, repoID int32) error

func (*Files) Map

func (f *Files) Map() map[string]int64

Map returns a path → file_id map.

type Hash

type Hash [20]byte

func NewHash

func NewHash(s string) Hash
func (h Hash) Link(repoURL string) template.HTML

func (*Hash) Scan

func (h *Hash) Scan(v any) error

func (Hash) Short

func (h Hash) Short() string

func (Hash) String

func (h Hash) String() string

func (Hash) URL

func (h Hash) URL(repoURL string) template.URL

func (Hash) Value

func (h Hash) Value() (driver.Value, error)

type Ints

type Ints []int64

func (*Ints) Scan

func (l *Ints) Scan(v any) error

func (Ints) String

func (l Ints) String() string

func (Ints) Sum

func (l Ints) Sum() int64

func (Ints) Value

func (l Ints) Value() (driver.Value, error)

type Repo

type Repo struct {
	ID            int32      `db:"repo_id,id"`
	Path          string     `db:"path"`
	Name          string     `db:"name"`
	FirstCommit   *Hash      `db:"first_commit"`
	LastCommit    *Hash      `db:"last_commit"`
	FirstCommitAt *time.Time `db:"first_commit_at"`
	LastCommitAt  *time.Time `db:"last_commit_at"`

	Commits int `db:"commits,noinsert"`
}

func (*Repo) ByName

func (r *Repo) ByName(ctx context.Context, name string) error

func (*Repo) ByPath

func (r *Repo) ByPath(ctx context.Context, path string) error

func (*Repo) Find

func (r *Repo) Find(ctx context.Context, name string) error

func (*Repo) Insert

func (r *Repo) Insert(ctx context.Context) error

func (Repo) Remote

func (r Repo) Remote() bool

func (*Repo) Update

func (r *Repo) Update(ctx context.Context) error

type Repos

type Repos []Repo

func (*Repos) List

func (s *Repos) List(ctx context.Context) error

type Strings

type Strings []string

func (Strings) Join

func (l Strings) Join(sep string) string

func (*Strings) Scan

func (l *Strings) Scan(v any) error

func (Strings) String

func (l Strings) String() string

func (Strings) Value

func (l Strings) Value() (driver.Value, error)

Source Files

author.go commit.go event.go file.go helper.go init.go repo.go

Directories

PathSynopsis
cmd
cmd/git-stats
db2
Version
v0.0.0-20240410145522-3037a55246c2 (latest)
Published
Apr 10, 2024
Platform
linux/amd64
Imports
21 packages
Last checked
1 month ago

Tools for package owners.