Skip to content

tenets.core.git Package

Git integration package.

This package provides comprehensive git repository analysis capabilities including repository metrics, blame analysis, history chronicling, and statistical insights. It extracts valuable context from version control history to understand code evolution, team dynamics, and development patterns.

The git package enables tenets to leverage version control information for better context building, all without requiring any external API calls.

Main components: - GitAnalyzer: Core git repository analyzer - BlameAnalyzer: Line-by-line authorship tracking - Chronicle: Repository history narrative generator - GitStatsAnalyzer: Comprehensive repository statistics

Example usage

from tenets.core.git import GitAnalyzer from tenets.config import TenetsConfig

config = TenetsConfig() analyzer = GitAnalyzer(config)

Get recent commits

commits = analyzer.get_recent_commits(limit=10) for commit in commits: print(f"{commit['sha']}: {commit['message']}")

Analyze repository statistics

from tenets.core.git import analyze_git_stats stats = analyze_git_stats(Path(".")) print(f"Health score: {stats.health_score}")

Classes

CommitInfodataclass

Python
CommitInfo(hexsha: str, author: str, email: str, message: str, committed_date: int)

Attributes

hexshainstance-attribute
Python
hexsha: str
authorinstance-attribute
Python
author: str
emailinstance-attribute
Python
email: str
messageinstance-attribute
Python
message: str
committed_dateinstance-attribute
Python
committed_date: int

GitAnalyzer

Python
GitAnalyzer(root: Any)

Attributes

rootinstance-attribute
Python
root = Path(base)
repoinstance-attribute
Python
repo: Optional[Repo] = None

Functions

is_repo
Python
is_repo() -> bool
is_git_repo
Python
is_git_repo(path: Optional[Path] = None) -> bool

Return True if the given path (or current root) is inside a git repo.

If a path is provided, update internal root and repo accordingly.

changed_files
Python
changed_files(ref: str = 'HEAD', diff_with: Optional[str] = None) -> List[Path]
get_recent_commits
Python
get_recent_commits(path: Optional[Path] = None, limit: int = 10, files: Optional[List[str]] = None) -> List[Dict[str, Any]]

Return recent commits as dictionaries suitable for formatting.

Each item contains: sha, author, email, message, date (ISO date string).

get_contributors
Python
get_contributors(path: Optional[Path] = None, files: Optional[List[str]] = None, limit: int = 20) -> List[Dict[str, Any]]

Return contributors with commit counts.

Returns a list of dicts: { name, email, commits } sorted by commits desc.

get_current_branch
Python
get_current_branch(path: Optional[Path] = None) -> str

Return current branch name, or 'HEAD' when detached/unknown.

current_branch
Python
current_branch() -> str

Alias for get_current_branch() for backward compatibility.

get_tracked_files
Python
get_tracked_files() -> List[str]

Return list of tracked files in the repository.

get_file_history
Python
get_file_history(file_path: str) -> List[Any]

Return commit history for a specific file.

commit_count
Python
commit_count() -> int

Return total number of commits in the repository.

list_authors
Python
list_authors() -> List[str]

Return list of unique authors in the repository.

author_stats
Python
author_stats() -> Dict[str, Dict[str, Any]]

Return statistics by author.

get_changes_since
Python
get_changes_since(path: Optional[Path] = None, since: str = '1 week ago', files: Optional[List[str]] = None) -> List[Dict[str, Any]]

Return a lightweight list of changes since a given time.

Each item contains: sha, message, date.

get_commits_since
Python
get_commits_since(since: datetime, max_count: int = 1000, author: Optional[str] = None, branch: Optional[str] = None, include_merges: bool = True) -> List[Any]

Return raw commit objects since a given datetime.

PARAMETERDESCRIPTION
since

Start datetime (inclusive)

TYPE:datetime

max_count

Maximum number of commits

TYPE:intDEFAULT:1000

author

Optional author filter

TYPE:Optional[str]DEFAULT:None

branch

Optional branch name

TYPE:Optional[str]DEFAULT:None

include_merges

Whether to include merge commits

TYPE:boolDEFAULT:True

RETURNSDESCRIPTION
List[Any]

List of GitPython commit objects

get_commits
Python
get_commits(since: Optional[datetime] = None, until: Optional[datetime] = None, max_count: int = 1000, author: Optional[str] = None, branch: Optional[str] = None) -> List[Dict[str, Any]]

Return commits between two dates.

This method was missing and called by momentum.py.

PARAMETERDESCRIPTION
since

Start datetime (inclusive)

TYPE:Optional[datetime]DEFAULT:None

until

End datetime (exclusive)

TYPE:Optional[datetime]DEFAULT:None

max_count

Maximum number of commits

TYPE:intDEFAULT:1000

author

Optional author filter

TYPE:Optional[str]DEFAULT:None

branch

Optional branch name

TYPE:Optional[str]DEFAULT:None

RETURNSDESCRIPTION
List[Dict[str, Any]]

List of commit dictionaries with standard fields

recent_commits
Python
recent_commits(limit: int = 50, paths: Optional[List[Path]] = None) -> List[CommitInfo]
blame
Python
blame(file_path: Path) -> List[Tuple[str, str]]

Return list of (author, line) for a file using git blame.

BlameAnalyzer

Python
BlameAnalyzer(config: TenetsConfig)

Analyzer for git blame operations.

Provides line-by-line authorship analysis using git blame, helping understand code ownership and evolution patterns.

ATTRIBUTEDESCRIPTION
config

Configuration object

logger

Logger instance

_blame_cache

Cache for blame results

TYPE:Dict[str, FileBlame]

Initialize blame analyzer.

PARAMETERDESCRIPTION
config

TenetsConfig instance

TYPE:TenetsConfig

Attributes

configinstance-attribute
Python
config = config
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

analyze_file
Python
analyze_file(repo_path: Path, file_path: str, ignore_whitespace: bool = True, follow_renames: bool = True) -> FileBlame

Analyze blame for a single file.

Performs git blame analysis on a file to understand line-by-line authorship.

PARAMETERDESCRIPTION
repo_path

Path to git repository

TYPE:Path

file_path

Path to file relative to repo root

TYPE:str

ignore_whitespace

Ignore whitespace changes

TYPE:boolDEFAULT:True

follow_renames

Follow file renames

TYPE:boolDEFAULT:True

RETURNSDESCRIPTION
FileBlame

Blame analysis for the file

TYPE:FileBlame

Example

analyzer = BlameAnalyzer(config) blame = analyzer.analyze_file(Path("."), "src/main.py") print(f"Primary author: {blame.primary_author}")

analyze_directory
Python
analyze_directory(repo_path: Path, directory: str = '.', file_pattern: str = '*', recursive: bool = True, max_files: int = 100) -> BlameReport

Analyze blame for all files in a directory.

Performs comprehensive blame analysis across multiple files to understand ownership patterns.

PARAMETERDESCRIPTION
repo_path

Path to git repository

TYPE:Path

directory

Directory to analyze

TYPE:strDEFAULT:'.'

file_pattern

File pattern to match

TYPE:strDEFAULT:'*'

recursive

Whether to recurse into subdirectories

TYPE:boolDEFAULT:True

max_files

Maximum files to analyze

TYPE:intDEFAULT:100

RETURNSDESCRIPTION
BlameReport

Comprehensive blame analysis

TYPE:BlameReport

Example

analyzer = BlameAnalyzer(config) report = analyzer.analyze_directory( ... Path("."), ... directory="src", ... file_pattern="*.py" ... ) print(f"Bus factor: {report.bus_factor}")

get_line_history
Python
get_line_history(repo_path: Path, file_path: str, line_number: int, max_depth: int = 10) -> List[Dict[str, Any]]

Get history of changes for a specific line.

Traces the evolution of a specific line through git history.

PARAMETERDESCRIPTION
repo_path

Path to git repository

TYPE:Path

file_path

Path to file

TYPE:str

line_number

Line number to trace

TYPE:int

max_depth

Maximum history depth to retrieve

TYPE:intDEFAULT:10

RETURNSDESCRIPTION
List[Dict[str, Any]]

List[Dict[str, Any]]: History of line changes

Example

analyzer = BlameAnalyzer(config) history = analyzer.get_line_history( ... Path("."), ... "src/main.py", ... 42 ... ) for change in history: ... print(f"{change['date']}: {change['author']}")

BlameLinedataclass

Python
BlameLine(line_number: int, content: str, author: str, author_email: str, commit_sha: str, commit_date: datetime, commit_message: str, is_original: bool = False, age_days: int = 0, previous_authors: List[str] = list())

Information for a single line from git blame.

Represents authorship information for a specific line of code, including who wrote it, when, and in which commit.

ATTRIBUTEDESCRIPTION
line_number

Line number in file

TYPE:int

content

Content of the line

TYPE:str

author

Author name

TYPE:str

author_email

Author email

TYPE:str

commit_sha

Commit SHA that introduced this line

TYPE:str

commit_date

Date when line was introduced

TYPE:datetime

commit_message

Commit message (first line)

TYPE:str

is_original

Whether this is from the original commit

TYPE:bool

age_days

Age of the line in days

TYPE:int

previous_authors

List of previous authors if line was modified

TYPE:List[str]

Attributes

line_numberinstance-attribute
Python
line_number: int
contentinstance-attribute
Python
content: str
authorinstance-attribute
Python
author: str
author_emailinstance-attribute
Python
author_email: str
commit_shainstance-attribute
Python
commit_sha: str
commit_dateinstance-attribute
Python
commit_date: datetime
commit_messageinstance-attribute
Python
commit_message: str
is_originalclass-attributeinstance-attribute
Python
is_original: bool = False
age_daysclass-attributeinstance-attribute
Python
age_days: int = 0
previous_authorsclass-attributeinstance-attribute
Python
previous_authors: List[str] = field(default_factory=list)
is_recentproperty
Python
is_recent: bool

Check if line was recently modified.

RETURNSDESCRIPTION
bool

True if modified within last 30 days

TYPE:bool

is_oldproperty
Python
is_old: bool

Check if line is old.

RETURNSDESCRIPTION
bool

True if older than 180 days

TYPE:bool

is_documentationproperty
Python
is_documentation: bool

Check if line appears to be documentation.

RETURNSDESCRIPTION
bool

True if line looks like documentation

TYPE:bool

is_emptyproperty
Python
is_empty: bool

Check if line is empty or whitespace only.

RETURNSDESCRIPTION
bool

True if empty or whitespace

TYPE:bool

BlameReportdataclass

Python
BlameReport(files_analyzed: int = 0, total_lines: int = 0, total_authors: int = 0, file_blames: Dict[str, FileBlame] = dict(), author_summary: Dict[str, Dict[str, Any]] = dict(), ownership_distribution: Dict[str, float] = dict(), collaboration_matrix: Dict[Tuple[str, str], int] = dict(), knowledge_map: Dict[str, Set[str]] = dict(), recommendations: List[str] = list(), hot_files: List[Dict[str, Any]] = list(), single_author_files: List[str] = list(), abandoned_code: Dict[str, int] = dict(), _bus_factor_override: Optional[int] = None, _collab_score_override: Optional[float] = None)

Comprehensive blame analysis report.

Provides detailed authorship analysis across multiple files, identifying ownership patterns, knowledge distribution, and collaboration insights.

ATTRIBUTEDESCRIPTION
files_analyzed

Number of files analyzed

TYPE:int

total_lines

Total lines analyzed

TYPE:int

total_authors

Total unique authors

TYPE:int

file_blames

Blame data for each file

TYPE:Dict[str, FileBlame]

author_summary

Summary statistics per author

TYPE:Dict[str, Dict[str, Any]]

ownership_distribution

How ownership is distributed

TYPE:Dict[str, float]

collaboration_matrix

Who modified whose code

TYPE:Dict[Tuple[str, str], int]

knowledge_map

Knowledge areas per author

TYPE:Dict[str, Set[str]]

recommendations

Actionable recommendations

TYPE:List[str]

hot_files

Files with most contributors

TYPE:List[Dict[str, Any]]

single_author_files

Files with only one author

TYPE:List[str]

abandoned_code

Code from inactive authors

TYPE:Dict[str, int]

Attributes

files_analyzedclass-attributeinstance-attribute
Python
files_analyzed: int = 0
total_linesclass-attributeinstance-attribute
Python
total_lines: int = 0
total_authorsclass-attributeinstance-attribute
Python
total_authors: int = 0
file_blamesclass-attributeinstance-attribute
Python
file_blames: Dict[str, FileBlame] = field(default_factory=dict)
author_summaryclass-attributeinstance-attribute
Python
author_summary: Dict[str, Dict[str, Any]] = field(default_factory=dict)
ownership_distributionclass-attributeinstance-attribute
Python
ownership_distribution: Dict[str, float] = field(default_factory=dict)
collaboration_matrixclass-attributeinstance-attribute
Python
collaboration_matrix: Dict[Tuple[str, str], int] = field(default_factory=dict)
knowledge_mapclass-attributeinstance-attribute
Python
knowledge_map: Dict[str, Set[str]] = field(default_factory=dict)
recommendationsclass-attributeinstance-attribute
Python
recommendations: List[str] = field(default_factory=list)
hot_filesclass-attributeinstance-attribute
Python
hot_files: List[Dict[str, Any]] = field(default_factory=list)
single_author_filesclass-attributeinstance-attribute
Python
single_author_files: List[str] = field(default_factory=list)
abandoned_codeclass-attributeinstance-attribute
Python
abandoned_code: Dict[str, int] = field(default_factory=dict)
bus_factorpropertywritable
Python
bus_factor: int

Calculate bus factor based on blame data.

RETURNSDESCRIPTION
int

Bus factor (number of critical authors)

TYPE:int

collaboration_scorepropertywritable
Python
collaboration_score: float

Calculate collaboration score.

Higher scores indicate more collaborative development.

RETURNSDESCRIPTION
float

Collaboration score (0-100)

TYPE:float

Functions

to_dict
Python
to_dict() -> Dict[str, Any]

Convert report to dictionary.

RETURNSDESCRIPTION
Dict[str, Any]

Dict[str, Any]: Dictionary representation

FileBlamedataclass

Python
FileBlame(file_path: str, total_lines: int = 0, blame_lines: List[BlameLine] = list(), authors: Set[str] = set(), author_stats: Dict[str, Dict[str, Any]] = dict(), commit_shas: Set[str] = set(), oldest_line: Optional[BlameLine] = None, newest_line: Optional[BlameLine] = None, age_distribution: Dict[str, int] = dict(), ownership_map: Dict[str, List[Tuple[int, int]]] = dict(), hot_spots: List[Tuple[int, int]] = list())

Blame information for an entire file.

Aggregates line-by-line blame information to provide file-level authorship insights and ownership patterns.

ATTRIBUTEDESCRIPTION
file_path

Path to the file

TYPE:str

total_lines

Total number of lines

TYPE:int

blame_lines

List of blame information per line

TYPE:List[BlameLine]

authors

Set of unique authors

TYPE:Set[str]

author_stats

Statistics per author

TYPE:Dict[str, Dict[str, Any]]

commit_shas

Set of unique commits

TYPE:Set[str]

oldest_line

Oldest line in file

TYPE:Optional[BlameLine]

newest_line

Newest line in file

TYPE:Optional[BlameLine]

age_distribution

Distribution of line ages

TYPE:Dict[str, int]

ownership_map

Line ranges owned by each author

TYPE:Dict[str, List[Tuple[int, int]]]

hot_spots

Lines that changed frequently

TYPE:List[Tuple[int, int]]

Attributes

file_pathinstance-attribute
Python
file_path: str
total_linesclass-attributeinstance-attribute
Python
total_lines: int = 0
blame_linesclass-attributeinstance-attribute
Python
blame_lines: List[BlameLine] = field(default_factory=list)
authorsclass-attributeinstance-attribute
Python
authors: Set[str] = field(default_factory=set)
author_statsclass-attributeinstance-attribute
Python
author_stats: Dict[str, Dict[str, Any]] = field(default_factory=dict)
commit_shasclass-attributeinstance-attribute
Python
commit_shas: Set[str] = field(default_factory=set)
oldest_lineclass-attributeinstance-attribute
Python
oldest_line: Optional[BlameLine] = None
newest_lineclass-attributeinstance-attribute
Python
newest_line: Optional[BlameLine] = None
age_distributionclass-attributeinstance-attribute
Python
age_distribution: Dict[str, int] = field(default_factory=dict)
ownership_mapclass-attributeinstance-attribute
Python
ownership_map: Dict[str, List[Tuple[int, int]]] = field(default_factory=dict)
hot_spotsclass-attributeinstance-attribute
Python
hot_spots: List[Tuple[int, int]] = field(default_factory=list)
primary_authorproperty
Python
primary_author: Optional[str]

Get the primary author of the file.

RETURNSDESCRIPTION
Optional[str]

Optional[str]: Author with most lines or None

author_diversityproperty
Python
author_diversity: float

Calculate author diversity score.

Higher scores indicate more distributed authorship.

RETURNSDESCRIPTION
float

Diversity score (0-1)

TYPE:float

average_age_daysproperty
Python
average_age_days: float

Calculate average age of lines in days.

RETURNSDESCRIPTION
float

Average age in days

TYPE:float

freshness_scoreproperty
Python
freshness_score: float

Calculate code freshness score.

Higher scores indicate more recently modified code.

RETURNSDESCRIPTION
float

Freshness score (0-100)

TYPE:float

Chronicle

Python
Chronicle(config: TenetsConfig)

Main chronicle analyzer for git repositories.

Analyzes git history to create a narrative view of repository evolution, identifying patterns, trends, and significant events.

ATTRIBUTEDESCRIPTION
config

Configuration object

logger

Logger instance

git_analyzer

Git analyzer instance

TYPE:Optional[GitAnalyzer]

Initialize chronicle analyzer.

PARAMETERDESCRIPTION
config

TenetsConfig instance

TYPE:TenetsConfig

Attributes

configinstance-attribute
Python
config = config
loggerinstance-attribute
Python
logger = get_logger(__name__)
git_analyzerinstance-attribute
Python
git_analyzer: Optional[GitAnalyzer] = None

Functions

analyze
Python
analyze(repo_path: Path, since: Optional[str] = None, until: Optional[str] = None, author: Optional[str] = None, branch: Optional[str] = None, include_merges: bool = True, include_stats: bool = True, max_commits: int = 1000) -> ChronicleReport

Analyze repository history and create chronicle report.

Creates a comprehensive narrative of repository evolution including commits, contributors, trends, and significant events.

PARAMETERDESCRIPTION
repo_path

Path to git repository

TYPE:Path

since

Start date or relative time (e.g., "2 weeks ago")

TYPE:Optional[str]DEFAULT:None

until

End date or relative time

TYPE:Optional[str]DEFAULT:None

author

Filter by specific author

TYPE:Optional[str]DEFAULT:None

branch

Specific branch to analyze

TYPE:Optional[str]DEFAULT:None

include_merges

Whether to include merge commits

TYPE:boolDEFAULT:True

include_stats

Whether to include detailed statistics

TYPE:boolDEFAULT:True

max_commits

Maximum commits to analyze

TYPE:intDEFAULT:1000

RETURNSDESCRIPTION
ChronicleReport

Comprehensive chronicle analysis

TYPE:ChronicleReport

Example

chronicle = Chronicle(config) report = chronicle.analyze( ... Path("."), ... since="1 month ago", ... include_stats=True ... ) print(report.summary)

ChronicleBuilder

Python
ChronicleBuilder(config: Optional[TenetsConfig] = None)

High-level builder that assembles a simple chronicle dict for CLI.

This composes the existing Chronicle and GitAnalyzer without duplicating analysis logic. It converts inputs to what Chronicle expects and returns a compact, CLI-friendly dictionary.

The CLI tests patch this class, but we provide a functional default for real usage.

Attributes

configinstance-attribute
Python
config = config or TenetsConfig()
loggerinstance-attribute
Python
logger = get_logger(__name__)

Functions

build_chronicle
Python
build_chronicle(repo_path: Path, *, since: Optional[object] = None, until: Optional[object] = None, branch: Optional[str] = None, authors: Optional[List[str]] = None, include_merges: bool = True, limit: Optional[int] = None) -> Dict[str, Any]

Build a chronicle summary for the given repository.

PARAMETERDESCRIPTION
repo_path

Path to a git repository

TYPE:Path

since

Start time (datetime or relative/ISO string)

TYPE:Optional[object]DEFAULT:None

until

End time (datetime or relative/ISO string)

TYPE:Optional[object]DEFAULT:None

branch

Branch name to analyze

TYPE:Optional[str]DEFAULT:None

authors

Optional author filters (currently advisory)

TYPE:Optional[List[str]]DEFAULT:None

include_merges

Include merge commits

TYPE:boolDEFAULT:True

limit

Max commits to analyze (advisory to Chronicle)

TYPE:Optional[int]DEFAULT:None

RETURNSDESCRIPTION
Dict[str, Any]

A dictionary with keys expected by the CLI views.

ChronicleReportdataclass

Python
ChronicleReport(period_start: datetime, period_end: datetime, total_commits: int = 0, total_contributors: int = 0, commits: List[CommitSummary] = list(), daily_activity: List[DayActivity] = list(), contributor_stats: Dict[str, Dict[str, Any]] = dict(), commit_type_distribution: Dict[str, int] = dict(), file_change_frequency: List[Tuple[str, int]] = list(), hot_periods: List[Dict[str, Any]] = list(), quiet_periods: List[Dict[str, Any]] = list(), significant_events: List[Dict[str, Any]] = list(), trends: List[str] = list(), summary: str = '')

Comprehensive chronicle report of repository history.

Provides a complete narrative view of repository evolution including commits, contributors, trends, and significant events.

ATTRIBUTEDESCRIPTION
period_start

Start of chronicle period

TYPE:datetime

period_end

End of chronicle period

TYPE:datetime

total_commits

Total commits in period

TYPE:int

total_contributors

Total unique contributors

TYPE:int

commits

List of commit summaries

TYPE:List[CommitSummary]

daily_activity

Daily activity breakdown

TYPE:List[DayActivity]

contributor_stats

Statistics by contributor

TYPE:Dict[str, Dict[str, Any]]

commit_type_distribution

Distribution of commit types

TYPE:Dict[str, int]

file_change_frequency

Most frequently changed files

TYPE:List[Tuple[str, int]]

hot_periods

Periods of high activity

TYPE:List[Dict[str, Any]]

quiet_periods

Periods of low activity

TYPE:List[Dict[str, Any]]

significant_events

Notable events (releases, major changes)

TYPE:List[Dict[str, Any]]

trends

Identified trends in development

TYPE:List[str]

summary

Executive summary of the period

TYPE:str

Attributes

period_startinstance-attribute
Python
period_start: datetime
period_endinstance-attribute
Python
period_end: datetime
total_commitsclass-attributeinstance-attribute
Python
total_commits: int = 0
total_contributorsclass-attributeinstance-attribute
Python
total_contributors: int = 0
commitsclass-attributeinstance-attribute
Python
commits: List[CommitSummary] = field(default_factory=list)
daily_activityclass-attributeinstance-attribute
Python
daily_activity: List[DayActivity] = field(default_factory=list)
contributor_statsclass-attributeinstance-attribute
Python
contributor_stats: Dict[str, Dict[str, Any]] = field(default_factory=dict)
commit_type_distributionclass-attributeinstance-attribute
Python
commit_type_distribution: Dict[str, int] = field(default_factory=dict)
file_change_frequencyclass-attributeinstance-attribute
Python
file_change_frequency: List[Tuple[str, int]] = field(default_factory=list)
hot_periodsclass-attributeinstance-attribute
Python
hot_periods: List[Dict[str, Any]] = field(default_factory=list)
quiet_periodsclass-attributeinstance-attribute
Python
quiet_periods: List[Dict[str, Any]] = field(default_factory=list)
significant_eventsclass-attributeinstance-attribute
Python
significant_events: List[Dict[str, Any]] = field(default_factory=list)
trendsclass-attributeinstance-attribute
Python
trends: List[str] = field(default_factory=list)
summaryclass-attributeinstance-attribute
Python
summary: str = ''
most_active_dayproperty
Python
most_active_day: Optional[DayActivity]

Get the most active day.

RETURNSDESCRIPTION
Optional[DayActivity]

Optional[DayActivity]: Most active day or None

activity_levelproperty
Python
activity_level: str

Determine overall activity level.

RETURNSDESCRIPTION
str

Activity level (high, moderate, low)

TYPE:str

Functions

to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict[str, Any]: Dictionary representation

CommitSummarydataclass

Python
CommitSummary(sha: str, author: str, email: str, date: datetime, message: str, files_changed: int = 0, lines_added: int = 0, lines_removed: int = 0, is_merge: bool = False, is_revert: bool = False, tags: List[str] = list(), branch: Optional[str] = None, issue_refs: List[str] = list(), pr_refs: List[str] = list())

Summary information for a single commit.

Provides a concise representation of a commit with key information for historical analysis and reporting.

ATTRIBUTEDESCRIPTION
sha

Commit SHA (short form)

TYPE:str

author

Commit author name

TYPE:str

email

Author email

TYPE:str

date

Commit date

TYPE:datetime

message

Commit message (first line)

TYPE:str

files_changed

Number of files changed

TYPE:int

lines_added

Lines added

TYPE:int

lines_removed

Lines removed

TYPE:int

is_merge

Whether this is a merge commit

TYPE:bool

is_revert

Whether this is a revert commit

TYPE:bool

tags

Associated tags

TYPE:List[str]

branch

Branch name if available

TYPE:Optional[str]

issue_refs

Referenced issue numbers

TYPE:List[str]

pr_refs

Referenced PR numbers

TYPE:List[str]

Attributes

shainstance-attribute
Python
sha: str
authorinstance-attribute
Python
author: str
emailinstance-attribute
Python
email: str
dateinstance-attribute
Python
date: datetime
messageinstance-attribute
Python
message: str
files_changedclass-attributeinstance-attribute
Python
files_changed: int = 0
lines_addedclass-attributeinstance-attribute
Python
lines_added: int = 0
lines_removedclass-attributeinstance-attribute
Python
lines_removed: int = 0
is_mergeclass-attributeinstance-attribute
Python
is_merge: bool = False
is_revertclass-attributeinstance-attribute
Python
is_revert: bool = False
tagsclass-attributeinstance-attribute
Python
tags: List[str] = field(default_factory=list)
branchclass-attributeinstance-attribute
Python
branch: Optional[str] = None
issue_refsclass-attributeinstance-attribute
Python
issue_refs: List[str] = field(default_factory=list)
pr_refsclass-attributeinstance-attribute
Python
pr_refs: List[str] = field(default_factory=list)
net_linesproperty
Python
net_lines: int

Calculate net lines changed.

RETURNSDESCRIPTION
int

Lines added minus lines removed

TYPE:int

commit_typeproperty
Python
commit_type: str

Determine commit type from message.

RETURNSDESCRIPTION
str

Commit type (feat, fix, docs, etc.)

TYPE:str

Functions

to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict[str, Any]: Dictionary representation

DayActivitydataclass

Python
DayActivity(date: datetime, commits: List[CommitSummary] = list(), total_commits: int = 0, unique_authors: Set[str] = set(), lines_added: int = 0, lines_removed: int = 0, files_touched: Set[str] = set(), commit_types: Dict[str, int] = dict(), peak_hour: Optional[int] = None, first_commit_time: Optional[datetime] = None, last_commit_time: Optional[datetime] = None)

Activity summary for a single day.

Aggregates all repository activity for a specific day to provide daily development rhythm insights.

ATTRIBUTEDESCRIPTION
date

Date of activity

TYPE:datetime

commits

List of commits on this day

TYPE:List[CommitSummary]

total_commits

Total commit count

TYPE:int

unique_authors

Set of unique authors

TYPE:Set[str]

lines_added

Total lines added

TYPE:int

lines_removed

Total lines removed

TYPE:int

files_touched

Set of files modified

TYPE:Set[str]

commit_types

Distribution of commit types

TYPE:Dict[str, int]

peak_hour

Hour with most commits

TYPE:Optional[int]

first_commit_time

Time of first commit

TYPE:Optional[datetime]

last_commit_time

Time of last commit

TYPE:Optional[datetime]

Attributes

dateinstance-attribute
Python
date: datetime
commitsclass-attributeinstance-attribute
Python
commits: List[CommitSummary] = field(default_factory=list)
total_commitsclass-attributeinstance-attribute
Python
total_commits: int = 0
unique_authorsclass-attributeinstance-attribute
Python
unique_authors: Set[str] = field(default_factory=set)
lines_addedclass-attributeinstance-attribute
Python
lines_added: int = 0
lines_removedclass-attributeinstance-attribute
Python
lines_removed: int = 0
files_touchedclass-attributeinstance-attribute
Python
files_touched: Set[str] = field(default_factory=set)
commit_typesclass-attributeinstance-attribute
Python
commit_types: Dict[str, int] = field(default_factory=dict)
peak_hourclass-attributeinstance-attribute
Python
peak_hour: Optional[int] = None
first_commit_timeclass-attributeinstance-attribute
Python
first_commit_time: Optional[datetime] = None
last_commit_timeclass-attributeinstance-attribute
Python
last_commit_time: Optional[datetime] = None
net_linesproperty
Python
net_lines: int

Calculate net lines changed.

RETURNSDESCRIPTION
int

Net lines changed for the day

TYPE:int

productivity_scoreproperty
Python
productivity_score: float

Calculate daily productivity score.

RETURNSDESCRIPTION
float

Productivity score (0-100)

TYPE:float

CommitStatsdataclass

Python
CommitStats(total_commits: int = 0, commits_per_day: float = 0.0, commits_per_week: float = 0.0, commits_per_month: float = 0.0, commit_size_avg: float = 0.0, commit_size_median: float = 0.0, commit_size_std: float = 0.0, largest_commit: Dict[str, Any] = dict(), smallest_commit: Dict[str, Any] = dict(), merge_commits: int = 0, revert_commits: int = 0, fix_commits: int = 0, feature_commits: int = 0, hourly_distribution: List[int] = (lambda: [0] * 24)(), daily_distribution: List[int] = (lambda: [0] * 7)(), monthly_distribution: List[int] = (lambda: [0] * 12)())

Statistics for commits.

Provides detailed statistical analysis of commit patterns including frequency, size, timing, and distribution metrics.

ATTRIBUTEDESCRIPTION
total_commits

Total number of commits

TYPE:int

commits_per_day

Average commits per day

TYPE:float

commits_per_week

Average commits per week

TYPE:float

commits_per_month

Average commits per month

TYPE:float

commit_size_avg

Average commit size (lines changed)

TYPE:float

commit_size_median

Median commit size

TYPE:float

commit_size_std

Standard deviation of commit size

TYPE:float

largest_commit

Largest single commit

TYPE:Dict[str, Any]

smallest_commit

Smallest single commit

TYPE:Dict[str, Any]

merge_commits

Number of merge commits

TYPE:int

revert_commits

Number of revert commits

TYPE:int

fix_commits

Number of fix commits

TYPE:int

feature_commits

Number of feature commits

TYPE:int

hourly_distribution

Commits by hour of day

TYPE:List[int]

daily_distribution

Commits by day of week

TYPE:List[int]

monthly_distribution

Commits by month

TYPE:List[int]

Attributes

total_commitsclass-attributeinstance-attribute
Python
total_commits: int = 0
commits_per_dayclass-attributeinstance-attribute
Python
commits_per_day: float = 0.0
commits_per_weekclass-attributeinstance-attribute
Python
commits_per_week: float = 0.0
commits_per_monthclass-attributeinstance-attribute
Python
commits_per_month: float = 0.0
commit_size_avgclass-attributeinstance-attribute
Python
commit_size_avg: float = 0.0
commit_size_medianclass-attributeinstance-attribute
Python
commit_size_median: float = 0.0
commit_size_stdclass-attributeinstance-attribute
Python
commit_size_std: float = 0.0
largest_commitclass-attributeinstance-attribute
Python
largest_commit: Dict[str, Any] = field(default_factory=dict)
smallest_commitclass-attributeinstance-attribute
Python
smallest_commit: Dict[str, Any] = field(default_factory=dict)
merge_commitsclass-attributeinstance-attribute
Python
merge_commits: int = 0
revert_commitsclass-attributeinstance-attribute
Python
revert_commits: int = 0
fix_commitsclass-attributeinstance-attribute
Python
fix_commits: int = 0
feature_commitsclass-attributeinstance-attribute
Python
feature_commits: int = 0
hourly_distributionclass-attributeinstance-attribute
Python
hourly_distribution: List[int] = field(default_factory=lambda: [0] * 24)
daily_distributionclass-attributeinstance-attribute
Python
daily_distribution: List[int] = field(default_factory=lambda: [0] * 7)
monthly_distributionclass-attributeinstance-attribute
Python
monthly_distribution: List[int] = field(default_factory=lambda: [0] * 12)
merge_ratioproperty
Python
merge_ratio: float

Calculate merge commit ratio.

RETURNSDESCRIPTION
float

Ratio of merge commits to total

TYPE:float

fix_ratioproperty
Python
fix_ratio: float

Calculate fix commit ratio.

RETURNSDESCRIPTION
float

Ratio of fix commits to total

TYPE:float

peak_hourproperty
Python
peak_hour: int

Find peak commit hour.

RETURNSDESCRIPTION
int

Hour with most commits (0-23)

TYPE:int

peak_dayproperty
Python
peak_day: str

Find peak commit day.

RETURNSDESCRIPTION
str

Day with most commits

TYPE:str

ContributorStatsdataclass

Python
ContributorStats(total_contributors: int = 0, active_contributors: int = 0, new_contributors: int = 0, contributor_commits: Dict[str, int] = dict(), contributor_lines: Dict[str, int] = dict(), contributor_files: Dict[str, Set[str]] = dict(), top_contributors: List[Tuple[str, int]] = list(), contribution_inequality: float = 0.0, collaboration_graph: Dict[Tuple[str, str], int] = dict(), timezone_distribution: Dict[str, int] = dict(), retention_rate: float = 0.0, churn_rate: float = 0.0)

Statistics for contributors.

Provides analysis of contributor patterns, productivity metrics, and team dynamics based on git history.

ATTRIBUTEDESCRIPTION
total_contributors

Total unique contributors

TYPE:int

active_contributors

Contributors active in last 30 days

TYPE:int

new_contributors

New contributors in period

TYPE:int

contributor_commits

Commits per contributor

TYPE:Dict[str, int]

contributor_lines

Lines changed per contributor

TYPE:Dict[str, int]

contributor_files

Files touched per contributor

TYPE:Dict[str, Set[str]]

top_contributors

Most active contributors

TYPE:List[Tuple[str, int]]

contribution_inequality

Gini coefficient of contributions

TYPE:float

collaboration_graph

Who works with whom

TYPE:Dict[Tuple[str, str], int]

timezone_distribution

Contributors by timezone

TYPE:Dict[str, int]

retention_rate

Contributor retention rate

TYPE:float

churn_rate

Contributor churn rate

TYPE:float

Attributes

total_contributorsclass-attributeinstance-attribute
Python
total_contributors: int = 0
active_contributorsclass-attributeinstance-attribute
Python
active_contributors: int = 0
new_contributorsclass-attributeinstance-attribute
Python
new_contributors: int = 0
contributor_commitsclass-attributeinstance-attribute
Python
contributor_commits: Dict[str, int] = field(default_factory=dict)
contributor_linesclass-attributeinstance-attribute
Python
contributor_lines: Dict[str, int] = field(default_factory=dict)
contributor_filesclass-attributeinstance-attribute
Python
contributor_files: Dict[str, Set[str]] = field(default_factory=dict)
top_contributorsclass-attributeinstance-attribute
Python
top_contributors: List[Tuple[str, int]] = field(default_factory=list)
contribution_inequalityclass-attributeinstance-attribute
Python
contribution_inequality: float = 0.0
collaboration_graphclass-attributeinstance-attribute
Python
collaboration_graph: Dict[Tuple[str, str], int] = field(default_factory=dict)
timezone_distributionclass-attributeinstance-attribute
Python
timezone_distribution: Dict[str, int] = field(default_factory=dict)
retention_rateclass-attributeinstance-attribute
Python
retention_rate: float = 0.0
churn_rateclass-attributeinstance-attribute
Python
churn_rate: float = 0.0
avg_commits_per_contributorproperty
Python
avg_commits_per_contributor: float

Calculate average commits per contributor.

RETURNSDESCRIPTION
float

Average commits

TYPE:float

bus_factorproperty
Python
bus_factor: int

Calculate bus factor.

RETURNSDESCRIPTION
int

Number of key contributors

TYPE:int

collaboration_scoreproperty
Python
collaboration_score: float

Calculate collaboration score.

RETURNSDESCRIPTION
float

Collaboration score (0-100)

TYPE:float

FileStatsdataclass

Python
FileStats(total_files: int = 0, active_files: int = 0, new_files: int = 0, deleted_files: int = 0, file_changes: Dict[str, int] = dict(), file_sizes: Dict[str, int] = dict(), largest_files: List[Tuple[str, int]] = list(), most_changed: List[Tuple[str, int]] = list(), file_age: Dict[str, int] = dict(), file_churn: Dict[str, float] = dict(), hot_files: List[str] = list(), stable_files: List[str] = list(), file_types: Dict[str, int] = dict())

Statistics for files.

Provides analysis of file-level metrics including change frequency, size distribution, and file lifecycle patterns.

ATTRIBUTEDESCRIPTION
total_files

Total files in repository

TYPE:int

active_files

Files changed in period

TYPE:int

new_files

Files added in period

TYPE:int

deleted_files

Files deleted in period

TYPE:int

file_changes

Number of changes per file

TYPE:Dict[str, int]

file_sizes

Size distribution of files

TYPE:Dict[str, int]

largest_files

Largest files by line count

TYPE:List[Tuple[str, int]]

most_changed

Most frequently changed files

TYPE:List[Tuple[str, int]]

file_age

Age distribution of files

TYPE:Dict[str, int]

file_churn

Churn rate per file

TYPE:Dict[str, float]

hot_files

Files with high activity

TYPE:List[str]

stable_files

Files with low activity

TYPE:List[str]

file_types

Distribution by file type

TYPE:Dict[str, int]

Attributes

total_filesclass-attributeinstance-attribute
Python
total_files: int = 0
active_filesclass-attributeinstance-attribute
Python
active_files: int = 0
new_filesclass-attributeinstance-attribute
Python
new_files: int = 0
deleted_filesclass-attributeinstance-attribute
Python
deleted_files: int = 0
file_changesclass-attributeinstance-attribute
Python
file_changes: Dict[str, int] = field(default_factory=dict)
file_sizesclass-attributeinstance-attribute
Python
file_sizes: Dict[str, int] = field(default_factory=dict)
largest_filesclass-attributeinstance-attribute
Python
largest_files: List[Tuple[str, int]] = field(default_factory=list)
most_changedclass-attributeinstance-attribute
Python
most_changed: List[Tuple[str, int]] = field(default_factory=list)
file_ageclass-attributeinstance-attribute
Python
file_age: Dict[str, int] = field(default_factory=dict)
file_churnclass-attributeinstance-attribute
Python
file_churn: Dict[str, float] = field(default_factory=dict)
hot_filesclass-attributeinstance-attribute
Python
hot_files: List[str] = field(default_factory=list)
stable_filesclass-attributeinstance-attribute
Python
stable_files: List[str] = field(default_factory=list)
file_typesclass-attributeinstance-attribute
Python
file_types: Dict[str, int] = field(default_factory=dict)
avg_file_sizeproperty
Python
avg_file_size: float

Calculate average file size.

RETURNSDESCRIPTION
float

Average size in lines

TYPE:float

file_stabilityproperty
Python
file_stability: float

Calculate overall file stability.

RETURNSDESCRIPTION
float

Stability score (0-100)

TYPE:float

churn_rateproperty
Python
churn_rate: float

Calculate overall churn rate.

RETURNSDESCRIPTION
float

Average churn rate

TYPE:float

GitStatsAnalyzer

Python
GitStatsAnalyzer(config: TenetsConfig)

Analyzer for git repository statistics.

Provides comprehensive statistical analysis of git repositories to understand development patterns, team dynamics, and code health.

ATTRIBUTEDESCRIPTION
config

Configuration object

logger

Logger instance

git_analyzer

Git analyzer instance

TYPE:Optional[GitAnalyzer]

Initialize statistics analyzer.

PARAMETERDESCRIPTION
config

TenetsConfig instance

TYPE:TenetsConfig

Attributes

configinstance-attribute
Python
config = config
loggerinstance-attribute
Python
logger = get_logger(__name__)
git_analyzerinstance-attribute
Python
git_analyzer: Optional[GitAnalyzer] = None

Functions

analyze
Python
analyze(repo_path: Path, since: Optional[str] = None, until: Optional[str] = None, branch: Optional[str] = None, include_files: bool = True, include_languages: bool = True, max_commits: int = 10000) -> RepositoryStats

Analyze repository statistics.

Performs comprehensive statistical analysis of a git repository to provide insights into development patterns and health.

PARAMETERDESCRIPTION
repo_path

Path to git repository

TYPE:Path

since

Start date or relative time

TYPE:Optional[str]DEFAULT:None

until

End date or relative time

TYPE:Optional[str]DEFAULT:None

branch

Specific branch to analyze

TYPE:Optional[str]DEFAULT:None

include_files

Whether to include file statistics

TYPE:boolDEFAULT:True

include_languages

Whether to analyze languages

TYPE:boolDEFAULT:True

max_commits

Maximum commits to analyze

TYPE:intDEFAULT:10000

RETURNSDESCRIPTION
RepositoryStats

Comprehensive statistics

TYPE:RepositoryStats

Example

analyzer = GitStatsAnalyzer(config) stats = analyzer.analyze(Path(".")) print(f"Health score: {stats.health_score}")

RepositoryStatsdataclass

Python
RepositoryStats(repo_age_days: int = 0, total_commits: int = 0, total_contributors: int = 0, total_files: int = 0, total_lines: int = 0, languages: Dict[str, int] = dict(), commit_stats: CommitStats = CommitStats(), contributor_stats: ContributorStats = ContributorStats(), file_stats: FileStats = FileStats(), growth_rate: float = 0.0, activity_trend: str = 'stable', health_score: float = 0.0, risk_factors: List[str] = list(), strengths: List[str] = list())

Overall repository statistics.

Aggregates various statistical analyses to provide comprehensive insights into repository health and development patterns.

ATTRIBUTEDESCRIPTION
repo_age_days

Age of repository in days

TYPE:int

total_commits

Total commits

TYPE:int

total_contributors

Total contributors

TYPE:int

total_files

Total files

TYPE:int

total_lines

Total lines of code

TYPE:int

languages

Programming languages used

TYPE:Dict[str, int]

commit_stats

Commit statistics

TYPE:CommitStats

contributor_stats

Contributor statistics

TYPE:ContributorStats

file_stats

File statistics

TYPE:FileStats

growth_rate

Repository growth rate

TYPE:float

activity_trend

Recent activity trend

TYPE:str

health_score

Overall health score

TYPE:float

risk_factors

Identified risk factors

TYPE:List[str]

strengths

Identified strengths

TYPE:List[str]

Attributes

repo_age_daysclass-attributeinstance-attribute
Python
repo_age_days: int = 0
total_commitsclass-attributeinstance-attribute
Python
total_commits: int = 0
total_contributorsclass-attributeinstance-attribute
Python
total_contributors: int = 0
total_filesclass-attributeinstance-attribute
Python
total_files: int = 0
total_linesclass-attributeinstance-attribute
Python
total_lines: int = 0
languagesclass-attributeinstance-attribute
Python
languages: Dict[str, int] = field(default_factory=dict)
commit_statsclass-attributeinstance-attribute
Python
commit_stats: CommitStats = field(default_factory=CommitStats)
contributor_statsclass-attributeinstance-attribute
Python
contributor_stats: ContributorStats = field(default_factory=ContributorStats)
file_statsclass-attributeinstance-attribute
Python
file_stats: FileStats = field(default_factory=FileStats)
growth_rateclass-attributeinstance-attribute
Python
growth_rate: float = 0.0
activity_trendclass-attributeinstance-attribute
Python
activity_trend: str = 'stable'
health_scoreclass-attributeinstance-attribute
Python
health_score: float = 0.0
risk_factorsclass-attributeinstance-attribute
Python
risk_factors: List[str] = field(default_factory=list)
strengthsclass-attributeinstance-attribute
Python
strengths: List[str] = field(default_factory=list)

Functions

to_dict
Python
to_dict() -> Dict[str, Any]

Convert to dictionary representation.

RETURNSDESCRIPTION
Dict[str, Any]

Dict[str, Any]: Dictionary representation

Functions

analyze_repository

Python
analyze_repository(path: Optional[Path] = None, config: Optional[Any] = None) -> Dict[str, Any]

Analyze a git repository comprehensively.

This is a convenience function that creates a GitAnalyzer instance and performs basic repository analysis.

PARAMETERDESCRIPTION
path

Path to repository (defaults to current directory)

TYPE:Optional[Path]DEFAULT:None

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
Dict[str, Any]

Dictionary with repository information including branch,

Dict[str, Any]

recent commits, and contributors

Example

from tenets.core.git import analyze_repository

repo_info = analyze_repository(Path("./my_project")) print(f"Current branch: {repo_info['branch']}") print(f"Recent commits: {len(repo_info['recent_commits'])}") print(f"Contributors: {len(repo_info['contributors'])}")

get_git_context

Python
get_git_context(path: Optional[Path] = None, files: Optional[List[str]] = None, since: str = '1 week ago', config: Optional[Any] = None) -> Dict[str, Any]

Get git context for specific files or time period.

Retrieves relevant git information to provide context about recent changes, contributors, and activity patterns.

PARAMETERDESCRIPTION
path

Repository path (defaults to current directory)

TYPE:Optional[Path]DEFAULT:None

files

Specific files to get context for

TYPE:Optional[List[str]]DEFAULT:None

since

Time period to analyze (e.g., "2 weeks ago")

TYPE:strDEFAULT:'1 week ago'

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
Dict[str, Any]

Dictionary with git context including commits, contributors,

Dict[str, Any]

and activity summary

Example

from tenets.core.git import get_git_context

context = get_git_context( ... files=["src/main.py", "src/utils.py"], ... since="1 month ago" ... ) print(f"Changes: {len(context['commits'])}") print(f"Active contributors: {len(context['contributors'])}")

analyze_blame

Python
analyze_blame(repo_path: Path, target: str = '.', ignore_whitespace: bool = True, follow_renames: bool = True, max_files: int = 100, config: Optional[Any] = None) -> BlameReport

Analyze code ownership using git blame.

Performs line-by-line authorship analysis to understand code ownership patterns and identify knowledge holders.

PARAMETERDESCRIPTION
repo_path

Path to git repository

TYPE:Path

target

File or directory to analyze

TYPE:strDEFAULT:'.'

ignore_whitespace

Ignore whitespace changes in blame

TYPE:boolDEFAULT:True

follow_renames

Track file renames

TYPE:boolDEFAULT:True

max_files

Maximum files to analyze (for directories)

TYPE:intDEFAULT:100

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
BlameReport

BlameReport with comprehensive ownership analysis

Example

from tenets.core.git import analyze_blame

blame = analyze_blame(Path("."), target="src/") print(f"Bus factor: {blame.bus_factor}") print(f"Primary authors: {blame.author_summary}")

Analyze single file

file_blame = analyze_blame(Path("."), target="main.py") print(f"Primary author: {file_blame.primary_author}")

get_file_ownership

Python
get_file_ownership(repo_path: Path, file_path: str, config: Optional[Any] = None) -> Dict[str, Any]

Get ownership information for a specific file.

Quick function to get the primary author and ownership distribution for a single file.

PARAMETERDESCRIPTION
repo_path

Repository path

TYPE:Path

file_path

Path to file relative to repo

TYPE:str

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
Dict[str, Any]

Dictionary with ownership information

Example

from tenets.core.git import get_file_ownership

ownership = get_file_ownership(Path("."), "src/main.py") print(f"Primary author: {ownership['primary_author']}") print(f"Contributors: {ownership['contributors']}")

create_chronicle

Python
create_chronicle(repo_path: Path, since: Optional[str] = None, until: Optional[str] = None, author: Optional[str] = None, include_stats: bool = True, max_commits: int = 1000, config: Optional[Any] = None) -> ChronicleReport

Create a narrative chronicle of repository history.

Generates a comprehensive narrative view of repository evolution including commits, contributors, trends, and significant events.

PARAMETERDESCRIPTION
repo_path

Path to repository

TYPE:Path

since

Start date or relative time (e.g., "1 month ago")

TYPE:Optional[str]DEFAULT:None

until

End date or relative time

TYPE:Optional[str]DEFAULT:None

author

Filter by specific author

TYPE:Optional[str]DEFAULT:None

include_stats

Include detailed statistics

TYPE:boolDEFAULT:True

max_commits

Maximum commits to analyze

TYPE:intDEFAULT:1000

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
ChronicleReport

ChronicleReport with repository narrative

Example

from tenets.core.git import create_chronicle

chronicle = create_chronicle( ... Path("."), ... since="3 months ago", ... include_stats=True ... ) print(chronicle.summary) print(f"Activity level: {chronicle.activity_level}") for event in chronicle.significant_events: print(f"{event['date']}: {event['description']}")

get_recent_history

Python
get_recent_history(repo_path: Path, days: int = 7, config: Optional[Any] = None) -> Dict[str, Any]

Get recent repository history summary.

Quick function to get a summary of recent repository activity.

PARAMETERDESCRIPTION
repo_path

Repository path

TYPE:Path

days

Number of days to look back

TYPE:intDEFAULT:7

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
Dict[str, Any]

Dictionary with recent history summary

Example

from tenets.core.git import get_recent_history

history = get_recent_history(Path("."), days=14) print(f"Commits: {history['total_commits']}") print(f"Active contributors: {history['contributors']}") print(f"Most active day: {history['most_active_day']}")

analyze_git_stats

Python
analyze_git_stats(repo_path: Path, since: Optional[str] = None, until: Optional[str] = None, include_files: bool = True, include_languages: bool = True, max_commits: int = 10000, config: Optional[Any] = None) -> RepositoryStats

Analyze comprehensive repository statistics.

Performs statistical analysis of repository to understand development patterns, team dynamics, and code health.

PARAMETERDESCRIPTION
repo_path

Path to repository

TYPE:Path

since

Start date or relative time

TYPE:Optional[str]DEFAULT:None

until

End date or relative time

TYPE:Optional[str]DEFAULT:None

include_files

Whether to include file statistics

TYPE:boolDEFAULT:True

include_languages

Whether to analyze languages

TYPE:boolDEFAULT:True

max_commits

Maximum commits to analyze

TYPE:intDEFAULT:10000

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
RepositoryStats

RepositoryStats with comprehensive metrics

Example

from tenets.core.git import analyze_git_stats

stats = analyze_git_stats( ... Path("."), ... since="6 months ago", ... include_languages=True ... ) print(f"Health score: {stats.health_score}") print(f"Bus factor: {stats.contributor_stats.bus_factor}") print(f"Top languages: {stats.languages}")

View risk factors

for risk in stats.risk_factors: print(f"Risk: {risk}")

get_repository_health

Python
get_repository_health(repo_path: Path, config: Optional[Any] = None) -> Dict[str, Any]

Get a quick repository health assessment.

Provides a simplified health check with key metrics and actionable recommendations.

PARAMETERDESCRIPTION
repo_path

Repository path

TYPE:Path

config

Optional TenetsConfig instance

TYPE:Optional[Any]DEFAULT:None

RETURNSDESCRIPTION
Dict[str, Any]

Dictionary with health assessment

Example

from tenets.core.git import get_repository_health

health = get_repository_health(Path(".")) print(f"Score: {health['score']}/100") print(f"Status: {health['status']}") for issue in health['issues']: print(f"Issue: {issue}")

Modules