history

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package history mines the git log into the history layer of the graph: commits become Decision rows, and file co-occurrence across commits becomes CoChange pairs with lift.

It shells out to git rather than using a Go git implementation: git is always present where a repo is, and `git log --numstat` is far faster than in-process history walking on large histories (RFC-001 §7.1).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileCommits

func FileCommits(repoRoot, file string) map[string]bool

FileCommits returns the set of commit hashes that touched a file, capped to the mining window. It is the left side of a co-change intersection: the commits shared with a partner are those in BOTH files' sets. Empty (nil) when git is unavailable, so callers degrade to no enrichment.

func IsRepo

func IsRepo(dir string) bool

IsRepo reports whether dir is inside a git work tree.

func Mine

func Mine(repoRoot string, opts Options) ([]model.Decision, []model.CoChange, error)

Mine runs git log in repoRoot and returns decisions (all mined commits) plus co-change pairs (from commits passing the size filter). A repository with no commits yet yields empty results, not an error.

func PartnerFunctions

func PartnerFunctions(repoRoot, partner string, shared map[string]bool, limit int) []string

PartnerFunctions reports which functions of partner were most often touched in the commits it shares with another file (shared). It streams the partner's diff history (git log -U0 -p, capped + timed out) and tallies the hunk-header function context of the shared commits only. This is a factual report of what moved together — never a statistical claim. NOTE: shared is the co-change window's commit set; a bulk commit dropped from the lift metric (too many files) that still touched both files can contribute here — a known, minor over-count.

Types

type Options

type Options struct {
	// MaxCommits bounds the mined window. 0 means the default (5000).
	// Co-change lift is computed over this window, so it reflects recent
	// coupling rather than all-time archaeology.
	MaxCommits int
	// MaxFilesPerCommit drops bulk commits (formatting sweeps, vendoring,
	// mass renames) from co-change counting; they say nothing about
	// intentional coupling. 0 means the default (30). Dropped commits are
	// still recorded as decisions.
	MaxFilesPerCommit int
	// MinTogether is the minimum number of shared commits for a pair to be
	// stored. 0 means the default (2).
	MinTogether int
}

Options tune the mining pass.

Jump to

Keyboard shortcuts

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