Skip to main content

commits2pdf

Licence PyPI version Publish to PyPI.org Release Issues CodeQL Tests

Visualise a Git repository's commit history in PDF form via the command-line

ezgif-pdf-tutorial

Dependencies

GitPython fpdf progressbar pathvalidate

pycairo (used for deprecated PDF generation method, must be installed manually)

Installation

  1. Make a virtual environment and activate it (recommended):

    • Before you make a virtual environment, you should change your current directory to the folder of your repository. If you don't know how, read Changing your terminal's directory.
    • If you are on Windows and you cannot activate the virtual environment, try running Set-ExecutionPolicy Unrestricted -Scope Process and try again.
pip install virtualenv
python -m venv venv
MacOS/Unix: source venv/bin/activate
Windows: venv\scripts\activate
  1. Install the package in your system directory/virtual environment:
pip install -U commits2pdf

or, install the package in your home directory if you aren't using a virtual environment:

pip install --user -U commits2pdf
  1. You can deactivate your virtual environment when you are done:
deactivate

Changing your terminal's directory

  1. Open your terminal
  2. Find your repository's folder
  3. (a) On Windows/Linux: Open the folder, press CTRL+L, then press CTRL+C. Alternatively, right click on the folder and click Copy as path.
  4. (b) On MacOS: Right click on the folder, hold option (⌥) and click Copy <folder name> as Pathname

Then, in your terminal, run cd <the path you copied> (paste in the path with CTRL+V or CMD+V).

Command-line parameters

There are many ways to configure the process of PDF generation through command line flags. For a brief introduction on how to use these flags, read Usage

Positional Flags

owner : The owner of the git repository. Required.

Optional Flags

-o, --output : Directory path to your PDF output. Set to . (your current directory) by default. Will be created if it does not exist. Example: ./work/my_pdfs

-n, --name : The name of your outputted PDF file. Set to <repo_name>-commit_report by default.

-b, --branch : The repository branch. Set to main by default.

-a, --authors : Filter commits from a comma-separated list of authors. Format: <author@email.com> OR <author1@email.com,author2@email.com> etc. Set to all authors by default.

-s, --start-date : Filter from start date of commits. Format: d/m/YYYY. Example: 5/12/2023

-e, --end-date : Filter to end date of commits. Format: d/m/YYYY. Example: 5/12/2023

-r, --reverse : Output the commits from newest to oldest. Set to oldest to newest by default

-d, --dark : Toggle dark mode for the output PDF. Set to light by default.

-po, --prevent-open : Prevent commits2pdf from automatically opening the directory the PDF was created in.

-sc, --scaling : Set the scaling of the output PDF. Only available with -gen2a and -gen2b.

-in, --include : Include commits with the given string sequences in their title or description. Format: <string1> OR <string1,string2>. Whitespace sensitive and case insensitive. NOTE: This query is performed BEFORE excluding commits.

-ex, --exclude : Exclude commits with the given string sequences in their title or description. Format: <string1> OR <string1,string2>. Whitespace sensitive and case insensitive.

-q, --quiet : Suppress all logger messages except for errors.

-gen1, --pdf-gen-1 : PDF rendering implementation with pycairo.

-gen2a, --pdf-gen-2a : The first PDF rendering implementation with fpdf.

-gen2b, --pdf-gen-2b : The second PDF rendering implementation with fpdf. The default option.

-rp, --repo-path : Path to your repository directory. Set to . (your current directory) by default.

-fc, --repo-from-clone : Clone a repo into the working directory and generate the commits PDF from it automatically. Format: <repo name> (case insensitive).

-nc, --newest-n-commits : Select the newest n number amount of commits to include after filtering.

-oc, --oldest-n-commits : Select the oldest n number amount of commits to include after filtering.

Usage

Usage example #1

c2p tomasvana10

Output a PDF to your current directory (assuming it is a git repository that is owned by tomasvana10).


Usage example #2

c2p tomasvana10 -o .. -rp ./my_repo -n "new_name.pdf"

Output a PDF (overriding its name to new_name) to the parent directory, selecting ./my_repo as your git repository to access the commits from.


Usage example #3

c2p tomasvana10 -nc 10 -in "javascript,build" -ex "testing"

Output a PDF to the current directory, displaying the newest 10 commits after filtering commits that contain "javascript" and/or "build" in their title or description and do not contain "testing".


Usage example #4

c2p devguarv -fc Yr-12-HSC-SDD-Task-2 -e 28/4/2024

Clone the repo Yr-12-HSC-SDD-Task-2 into the current directory and output a PDF into the same place after filtering commits that were made up to 28/4/2024.

PDF generation implementations

pycairo (gen1 - deprecated)

👍 Fast

👎 Cannot write multipage commits

👎 Looks like crap

👎 No hyperlinks, therefore the entire link to a commit's diff is displayed

fpdf (gen2a)

👍 Fast

👍 Can be scaled with the -sc <float> argument<

👍 Sleek design

👍 Information title page

👍 Contains hyperlinks

👍 Stores PDF metadata

👎 Inconsistent page breaks, a general limitation with FPDF when trying to fit as many whole commits on a single page

fpdf (gen2b - Default)

👍 Same as gen2a but with accurate page breaking

👎 Slow when generating large amounts of commits (generally, it is a good idea to enable -gen2a when drawing over 5000 commits)

Metadata

Release files for commits2pdf 1.1.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for commits2pdf 1.1.17
File Size Uploaded Provenance Actions
commits2pdf-1.1.17.tar.gz 20.4 kB Without provenance Details for commits2pdf-1.1.17.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for commits2pdf 1.1.17
File Interpreter ABI Platform Actions
commits2pdf-1.1.17-py3-none-any.whl Python 3 none any Details for commits2pdf-1.1.17-py3-none-any.whl

Total release size: 41.0 kB

Release files / commits2pdf-1.1.17.tar.gz

Download URL commits2pdf-1.1.17.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2fc8ca4348feaec480f658ea1cda9ee340e31864cfb604654e7d61c8389b8334
BLAKE2b-256 checksum
How to use checksums
06f3fa824f514de601b9a634bda671f5b5a45eef0c43abfd999d1106a1915201
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / commits2pdf-1.1.17-py3-none-any.whl

Download URL commits2pdf-1.1.17-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
552a3c1768a6884125b0bc765dc6f2eda47bad68acd4821a67385eca598c8308
BLAKE2b-256 checksum
How to use checksums
77e2bbe8b27428bd22518975c090a0c09e5f02eacc8bc740b72be940653616ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Security for commits2pdf 1.1.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page