habits

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package habits owns the M4 "habits" plugin. It derives "when do you commit" stats from the user's recent events feed. The full upstream behavior also analyzes commit diffs (lines / indent / chars per line) — the M4 MVP wires the day/hour histograms from PushEvents only, and exposes the input surface for the diff-based facts as a follow-up (commit-diff fetching lands alongside US3).

Index

Constants

View Source
const Name = "habits"

Name is the canonical plugin slug.

Variables

View Source
var Plugin plugins.Plugin = &habitsPlugin{}

Plugin is the singleton registered with the global plugin registry.

Functions

func Partial

Partial renders the classic SVG fragment for the habits plugin. Mirrors upstream org_repo/source/templates/classic/partials/habits.ejs.

Two sections are emitted:

  1. <section class="habits"> — header + facts list ("Mostly pushes code around HH:00", "Mostly active on Day", etc.)

  2. <section class="habits"> — chart-bars - <h3>Commit activity per hour of day</h3> + chart-bars (24 bars) - <h3>Commit activity per day of week</h3> + chart-bars (7 bars)

The chart-bars block emits plain HTML inside foreignObject (no bare SVG primitives), fixing the v1.0.0 bare-`<g>` invisibility bug.

Types

type HabitCharts

type HabitCharts struct {
	Hours [24]int `json:"hours"`
	Days  [7]int  `json:"days"`
}

HabitCharts holds the per-hour and per-weekday push event histogram.

type HabitFacts

type HabitFacts struct {
	LinesPerCommit float64 `json:"linesPerCommit"`
	CharsPerLine   float64 `json:"charsPerLine"`
	CommitsPerDay  float64 `json:"commitsPerDay"`
	IndentStyle    string  `json:"indentStyle"`
}

HabitFacts holds the diff-derived statistics. In M4 MVP these are zero-valued because commit-diff fetching is deferred.

type HabitLinguist added in v1.1.0

type HabitLinguist struct {
	Available bool            `json:"available"`
	Ordered   []LanguageShare `json:"ordered"`
}

HabitLinguist holds the "Language activity" breakdown derived from the files touched by recent PushEvent commits. Mirrors upstream's `plugins.habits.linguist` ({available, ordered}). Available is false when no analyzable files were found, which keeps the section out of the SVG exactly like upstream's `linguist.available` gate.

type LanguageShare added in v1.1.0

type LanguageShare struct {
	Name  string  `json:"name"`
	Share float64 `json:"share"`
}

LanguageShare is one (language, share) pair in the Language activity chart. Share is the 0..1 fraction of analyzed bytes attributed to the language, matching upstream's `linguist.ordered` entries.

type Result

type Result struct {
	Skipped       bool          `json:"skipped,omitempty"`
	SkippedReason string        `json:"-"`
	Days          int           `json:"days"`
	FactsEnabled  bool          `json:"factsEnabled"`
	ChartsEnabled bool          `json:"chartsEnabled"`
	Facts         HabitFacts    `json:"facts"`
	Charts        HabitCharts   `json:"charts"`
	Linguist      HabitLinguist `json:"linguist"`
	From          int           `json:"from"`
	Trim          bool          `json:"trim"`
}

Result is the JSON payload published under data.Plugins["habits"].

func (*Result) IsSkipped

func (r *Result) IsSkipped() bool

IsSkipped lets the classic dispatcher detect the skipped path.

Jump to

Keyboard shortcuts

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