Documentation
¶
Overview ¶
Package git provides helpers for querying git repository information.
Index ¶
- func BranchesForUser(user string, days int) ([]string, error)
- func IsGitRepo() bool
- func ListAllBranches() ([]string, error)
- func ListBranches() ([]string, error)
- func OpenInEditor(path string) tea.Cmd
- func OpenRevisionInEditor(hash, path string) tea.Cmd
- func SortedYears(m map[int]int) []int
- type BranchInfo
- type BranchUser
- type CommitInfo
- type DashboardRecentCommit
- type FileChange
- type UserDashboard
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchesForUser ¶
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 ¶
ListAllBranches returns both local and remote branch names (deduplicated).
func ListBranches ¶
ListBranches returns all local branch names.
func OpenInEditor ¶
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 ¶
OpenRevisionInEditor opens a specific revision of a file in the editor using a temporary file.
func SortedYears ¶
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 ¶
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 ¶
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 ¶
DashboardRecentCommit is a single line in the "recent activity" section.
type FileChange ¶
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.