View on GitHub

gh-commit-ledger

gh-commit-ledger

gh-commit-ledger

A TUI that displays the commit count of your public repositories. Written in Rust.

Features

Examples

Requirements

You can check the status of GitHub CLI with the following command:

gh auth status

If you are not logged in, please authenticate first.

gh auth login

Installation

cargo install --force --git https://github.com/cat2151/gh-commit-ledger

Execution

gh-commit-ledger

Update

gh-commit-ledger update

Usage

Aggregation starts automatically upon launch. The first run will fetch all target repositories, which may take some time depending on the number of repositories.

Configuration

If a configuration file does not exist when launched, config.toml will be created with default values.

On Windows, it is saved at %LOCALAPPDATA%\gh-commit-ledger\config.toml. The actual path is displayed in the TUI at config:.

The configuration directory can be overridden with the GH_COMMIT_LEDGER_CONFIG_DIR environment variable. In this case, config.toml and cache.json will be saved in the specified directory.

Pressing the e key opens the configuration file in an editor. The editors listed in editors will be tried in order. By default, the order is fresh, zed, code, edit, nano, vim.

You can change the message body copied to the clipboard using [clipboard].message. In the TUI, this message is displayed in a separate frame from the existing aggregation display.

editors = ["fresh", "zed", "code", "edit", "nano", "vim"]

[clipboard]
message = "昨日は {commits_yesterday} 件の commit をしました。\nこれまでの総 commit 数は {total_commits} 件です。"

The following two placeholders are available:

Placeholder Content
{commits_yesterday} Yesterday’s commit count
{total_commits} Total commit count

Aggregation Specifications

This tool uses “yesterday” and “the day before yesterday” as perceived in the local timezone as its basis.

Targets are public repositories of the authenticated GitHub CLI user. Forks are excluded. Repositories without a default branch or where the tip of the default branch cannot be treated as a commit are treated as 0.

The list of repositories is obtained using gh repo list <login> --limit 1000 --visibility public --source --no-archived=false from GitHub CLI.

Cache

The fetched results are saved under the OS’s local configuration directory, same as the settings file. The actual path is displayed in the TUI at cache:.

The cache stores the cumulative commit count for each repository at different points in time. During normal launch, it utilizes existing cache and fetches only the missing data from GitHub.

The cache retains up to 16 data points per repository, deleting older points when the limit is exceeded.

To force a re-fetch, press r in the TUI.

Detailed Specifications

Troubleshooting

Failed to launch gh command

GitHub CLI is either not installed or not included in your PATH. Please ensure that gh --version can be executed.

gh command failed

Please check GitHub CLI authentication, network connection, and GitHub API limits.

gh auth status
gh api user

Slow initial run

The first run makes API calls for all target public repositories. Subsequent runs use the cache, so aggregation for the same date will be faster.