Skip to main content

Parser for git log --raw

Project description

glrp - git log raw parser

A parser for parsing the output of git log, specifically with the --format=raw option. This is the intended git command to use:

git log -p --format=raw --show-signature --stat

Simply pipe the output:

git log -p --format=raw --show-signature --stat | glrp --pretty

The CLI outputs one JSON object per commit. Each JSON object is on one line, they are separated by newlines. This format is sometimes referred to as JSONL or JSON lines format. With --pretty, each JSON object is indented to be more readable and printed across multiple lines. (But then it is no longer JSONL, strictly speaking).

Why?

The above command provides a lot of useful information about each git commit, which we can analyze, including:

  • Commit message
  • Diff
  • Author name and email
  • Committer name and email
  • Timestamps
  • GPG signature

On its own, git log does not output its information in a format which is easy for other programs to use. So, this tool parses the output and turns it into JSON which is more easy to analyze and check.

Installation

pipx install glrp

Usage

Using it is simple. Run it inside a git repo:

glrp .

Or you can pipe git log output to it:

git log -p --format=raw --show-signature --stat | glrp --output-dir=./out/

Or perhaps a bit more realistic:

git clone https://github.com/cfengine/core
(cd core && git log -p --format=raw --show-signature --stat HEAD~500..HEAD 2>/dev/null) | glrp

(Clone CFEngine core, start subshell which enters the subdirectory and runs git log for the past 500 commits).

Specifying input

By default, glrp parses standard input, and outputs to stdout. To take input from somewhere else, supply a filename:

glrp some_file.jsonl

The file, some_file.jsonl is opened and read, its content is used instead of standard input. You can also specify the path to a folder:

glrp some_dir/

The glrp tool will run the git log command (git log -p --format=raw --show-signature --stat) inside that folder. Output from the git command will be parsed instead of standard input.

Specifying output

You can use shell redirection to print to file instead of standard output:

glrp . > output.txt

Important notes

Note: This tool is meant specifically as a parser for the command shown above, not as a generic parser for all the different things git log can output.

Warning: The output of --show-signature varies depending on which keys you have imported / trusted in your installation of GPG. Make sure you import the correct GPG keys beforehand, and don't expect output to be identical across different machines with different GPG states.

Warning: Consider this a best-effort, "lossy" parsing. Commits may contain non utf-8 characters, to avoid "crashing", we skip these, replacing them with question marks. Thus, the parsing is lossy, don't expect all the information to be there. This tool can be used for searching / analyzing commits, but don't use it as some kind of backup tool where you expect to have the ability to "reconstruct" the commits and repo entirely.

Details

For details on how the parsing works, try running with --debug and look at the resulting ./debug/ folder. Also, see the comments in the source code; ./glrp/internal_parser.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

glrp-0.0.9.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glrp-0.0.9-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file glrp-0.0.9.tar.gz.

File metadata

  • Download URL: glrp-0.0.9.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for glrp-0.0.9.tar.gz
Algorithm Hash digest
SHA256 05321b7f0b5755a5757c9b274e4ba2d0f11840cea7fa0bd236cb0958eecc00be
MD5 4822698292b128fa861b9d1aeef7f996
BLAKE2b-256 b5c1a70c23af396657561e693d628bb0803b788619c2653b209e90b72b9312fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for glrp-0.0.9.tar.gz:

Publisher: python-publish.yml on olehermanse/glrp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glrp-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: glrp-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for glrp-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d534293478e772c602faa3733391c3a056b1d7fefcd3aa9788a1204626fcca52
MD5 fe042ed08ec82e3a5a823281ba12718e
BLAKE2b-256 37803571fbd99e94567b76fa1a6cfaf03b09f5d035d9fa9bf665c8f60ef2c15e

See more details on using hashes here.

Provenance

The following attestation bundles were made for glrp-0.0.9-py3-none-any.whl:

Publisher: python-publish.yml on olehermanse/glrp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page