git

package
v0.0.0-...-d3d6d17 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package git provides helpers for querying git repository information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BranchesForUser

func BranchesForUser(user string, days int) ([]string, error)

BranchesForUser returns branches where the given user (by name or email) was active. days <= 0 means no time restriction.

func IsGitRepo

func IsGitRepo() bool

IsGitRepo returns true when the current directory is inside a git repository.

func ListAllBranches

func ListAllBranches() ([]string, error)

ListAllBranches returns both local and remote branch names (deduplicated).

func ListBranches

func ListBranches() ([]string, error)

ListBranches returns all local branch names.

func OpenInEditor

func OpenInEditor(path string) tea.Cmd

OpenInEditor attempts to open a file using the OS default associated application/app first. If that fails (e.g., xdg-open not handling the file/mime), it falls back to a best-effort default text editor for the platform (EDITOR/VISUAL or common editors).

func OpenRevisionInEditor

func OpenRevisionInEditor(hash, path string) tea.Cmd

OpenRevisionInEditor opens a specific revision of a file in the editor using a temporary file.

func SortedYears

func SortedYears(m map[int]int) []int

SortedYears returns calendar years in descending order for dashboard display.

Types

type BranchInfo

type BranchInfo struct {
	Branch string
	Users  []BranchUser
}

BranchInfo holds a branch name and the users active on it.

func BranchUsers

func BranchUsers() ([]BranchInfo, error)

BranchUsers returns all branches with their active users.

type BranchUser

type BranchUser struct {
	Name  string
	Email string
}

BranchUser represents a user who was active on a branch.

func AllUsers

func AllUsers() ([]BranchUser, error)

AllUsers returns all unique users who have committed to any branch.

func UsersOnBranch

func UsersOnBranch(branch string) ([]BranchUser, error)

UsersOnBranch returns the unique users who have committed on a branch.

type CommitInfo

type CommitInfo struct {
	Hash    string
	Author  string
	Date    string
	Subject string
	Body    string
}

CommitInfo holds information about a single git commit.

func CommitsForFile

func CommitsForFile(user, file, branch string, days int) ([]CommitInfo, error)

CommitsForFile returns detailed commit information for a specific file and user.

type DashboardRecentCommit

type DashboardRecentCommit struct {
	Hash    string
	DateISO string
	Subject string
}

DashboardRecentCommit is a single line in the "recent activity" section.

type FileChange

type FileChange struct {
	File    string
	Changes int
}

FileChange represents a file changed by a user.

func FilesTouchedByUser

func FilesTouchedByUser(user, branch string, days int) ([]FileChange, error)

FilesTouchedByUser returns files changed by the given user, optionally filtered by branch and/or a number of days. days <= 0 means no time restriction. branch == "" means all branches (uses --all).

type UserDashboard

type UserDashboard struct {
	User BranchUser
	Days int // filter window; 0 means entire history

	CommitsNonMerge int64
	CommitsMerge    int64

	FirstCommit time.Time
	LastCommit  time.Time
	HasActivity bool

	Insertions int64
	Deletions  int64

	Branches    []string
	BranchTotal int

	TopFiles []FileChange

	Recent []DashboardRecentCommit

	// CommitsByYear maps calendar year to number of non-merge commits (sorted years in UI).
	CommitsByYear map[int]int
}

UserDashboard aggregates repository statistics for one author identity.

func UserDashboardStats

func UserDashboardStats(u BranchUser, days int) (*UserDashboard, error)

UserDashboardStats loads statistics for the given author and optional day window. days <= 0 means no time restriction.

Jump to

Keyboard shortcuts

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