Socket
Book a DemoInstallSign in
Socket

@tenedev/git-log

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tenedev/git-log

Parse and format git commit history with ease supporting filters for tags dates authors and ranges

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

@tenedev/git-log

Parse and format git commit history with ease supporting filters for tags, dates, authors, and ranges

npm npm downloads

🪵 A lightweight git log parser & formatter for Node.js. Parse commit history into JSON, CSV, or Markdown — perfect for changelogs, release notes, or analytics. Supports filtering by tags, dates, authors, ranges, branches, and works efficiently with large repositories.

Install

pnpm add -D @tenedev/git-log
# or
npm install -D @tenedev/git-log
# or
yarn add -D @tenedev/git-log

Usage

CLI

npx @tenedev/git-log --help

CLI Examples

# Export commits since the last tag as pretty JSON
npx @tenedev/git-log --style json --pretty --output changelog.json

# Export commits as CSV with custom delimiter
npx @tenedev/git-log --style csv --delimiter ";" --output commits.csv

# Generate a Markdown table with commits since Jan 2024
npx @tenedev/git-log --style md --md-style table --since "2024-01-01" --output commits.md

# Show only commits by a specific author on main branch
npx @tenedev/git-log --author "Alice" --branch main --style json

# Limit to 5 commits in short format
npx @tenedev/git-log --fields shortHash,subject --limit 5

# Show full history (ignoring tags)
npx @tenedev/git-log --range all

Programmatic API

import getGitLog, {
  getLatestTag,
  getDefaultRange,
  GitField,
  LogOptions,
  FormatOptions,
} from '@tenedev/git-log';

// Example 1: commits since last tag in markdown
const log = getGitLog({
  fields: ['shortHash', 'author', 'date', 'subject'] as GitField[],
  style: 'md',
  mdStyle: 'table',
  range: { from: getLatestTag(), to: 'HEAD' },
  limit: 20,
});
console.log(log);

// Example 2: JSON logs across all history, custom date format
const jsonLog = getGitLog({
  fields: ['shortHash', 'formattedDate', 'subject'],
  style: 'json',
  pretty: true,
  range: 'all',
  dateFormat: 'DD-MM-YYYY',
});
console.log(jsonLog);

// Example 3: filter by author + date range
const filtered = getGitLog({
  fields: ['shortHash', 'author', 'date', 'subject'],
  style: 'csv',
  delimiter: ';',
  since: '2024-01-01',
  until: '2024-06-30',
  author: 'Bob',
});
console.log(filtered);

Options

LogOptions

OptionTypeDefaultDescription
fieldsGitField[]['hash','shortHash','author','email','date','subject','body']Commit fields to include
limitnumber | nullnullLimit number of commits
range'all' | { from: string; to?: string }{ from: latestTag, to: 'HEAD' }Commit range ('all' = full log)
sincestringundefinedFilter commits since given date
untilstringundefinedFilter commits until given date
authorstringundefinedFilter commits by author name/mail
branchstring"all"Branch to scan commits from

FormatOptions

OptionTypeDefaultDescription
style'json' | 'csv' | 'md''json'Output format
delimiter',' | ';'','CSV delimiter
mdStyle'block' | 'table' | 'list''block'Markdown rendering style
prettybooleantruePretty-print JSON
dateFormat'YYYY-MM-DD' | 'DD-MM-YYYY' | 'MM-DD-YYYY''YYYY-MM-DD'Custom format for formattedDate

GitField

  • hash — full commit hash (40 chars)
  • shortHash — short commit hash (7 chars)
  • author — author name
  • email — author email
  • date — commit date (git log --date=iso8601)
  • formattedDate — date formatted according to dateFormat
  • subject — commit subject (first line)
  • body — commit body (remaining lines)

Example Outputs

JSON

[
  {
    "shortHash": "a1b2c3d",
    "author": "Jane Doe",
    "date": "2024-08-10T12:00:00+00:00",
    "formattedDate": "10-08-2024",
    "subject": "feat: add new API endpoint"
  }
]

CSV

shortHash;author;date;subject
a1b2c3d;"Jane Doe";"2024-08-10T12:00:00+00:00";"feat: add new API endpoint"

Markdown (list)

- **shortHash**: a1b2c3d, **author**: Jane Doe, **subject**: feat: add new API endpoint

Edge cases:

  • Empty repository → returns [] (JSON) or empty string (CSV/MD).
  • If no tag exists → range falls back to 'all'.

License

Released under the Apache License 2.0.

Keywords

git

FAQs

Package last updated on 07 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts