Skip to main content

Get a representation of commits in a git repository as JSON

Project description

parsegitlog

python -m pip install parsegitlog

Context

I've been working on a project where I need to get information on every commit from serveral hundred repos, and using GitPython. GitPython is great, but it was a little slow for what I was trying to do.

The method of parsing the gitlog in this project is much faster for my use case.

Note that this project is much more narrow in scope than GitPython, and relies on parsing the output of git log directly, so might be more fragile.

You might find this useful if you only need to analyze the commits for a repo, and not perform any other git operations progromatically.

Usage

You can either import this as a module or run it from the command line.

Command Line

python -m parsegitlog --help
python -m parsegitlog

Importing

from parsegitlog import get_commits

repo_path = '/path/to/my/git/repository'

get_commits(repo_path)

get_commits will return a list of dicts, each dict representing a single commit from the repository.

Gotchas

Merge commits will show up multiple times. This is intended behavior.

Although they appear to be duplicates, the files_changed, insertions, and deletions for each will be slightly different, and there will be duplicate entries for each merge commit corresponding to the number of parents in the merge. This is because, depending on which parent we compare to, the difference from the parent (in terms of files changed, insertions, and deletions) won't be the same (every other property should be the same).

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

parsegitlog-0.0.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

parsegitlog-0.0.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file parsegitlog-0.0.3.tar.gz.

File metadata

  • Download URL: parsegitlog-0.0.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for parsegitlog-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1f88c598328b6f00a001bcafd991c0345f756f42bb35b234372127de64d6c881
MD5 abb3b9eb2a2037bf6ab6e8cf76969b2b
BLAKE2b-256 3d880d522caaf4af82e1e28e71c509091561dcd59b4e446d87873fcafc6f29b9

See more details on using hashes here.

File details

Details for the file parsegitlog-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: parsegitlog-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for parsegitlog-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9edcd984228c39597884ac2614fb52ee87f428bf17a4d9f72864c96a0362b5ea
MD5 b77ea69f61a50bc8d89f8cf32a368bbb
BLAKE2b-256 e635da327c791c59b5a63a9960bf72b6e5f03c96cd58044bac9138d72bf8e50f

See more details on using hashes here.

Supported by

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