Skip to main content

Git-Authorship

Interactive reports showing who wrote each line of code in your git repository.

Joseph Hale's software engineering blog

pip install git-authorship

git-authorship https://github.com/USERNAME/REPOSITORY

# Open build/authorship.html in a web browser

GIF demonstrating an interactive report of the authors of the cubing library cubing.js

Why?

Copyright is a thing, and whoever wrote the code in your repository holds an exclusive copyright over it unless an agreement has been made otherwise.

While git-authorship does not help with managing copyright agreements from contributors (see cla-assistant and its corresponding GitHub Action for that functionality), it does help you clearly identify who your contributors are and the exact lines of code they wrote.

To support libraries undergoing re-licensing, git-authorship includes config files for labelling the licenses under which contributors have shared their code.

Other Features

Mailmaps

When an author changes his/her commit name or email, that author will appear multiple times in the authorship report.

To reduce that noise, add a standard .mailmap file to the root of your git repository.

.mailmap

Proper Name <commit@email.xx>
<proper@email.xx> <commit@email.xx>
Proper Name <proper@email.xx> <commit@email.xx>
Proper Name <proper@email.xx> Commit Name <commit@email.xx>

Ignore Revs

Automated tools (e.g. linters/formatters) which change many lines can lead to authorship being attributed to the individual who ran the tool instead of the original author.

However, if you identify the formatting commits and list their full commit SHAs in a file, Git Authorship can correctly attribute the original author. The default file is .git-blame-ignore-revs, placed at the root of the repository.

.git-blame-ignore-revs

# Run automated formatter
9c6927b59791eb71cce0a84d8c88fa14d5235fa8

# Run automated linter
ba09bf70676fb13891d15236951450b2f1aa9f3b

You can specify an alternate location via the --ignore-revs-file option (resolved relative to the repository root).

git-authorship REPO_URL --ignore-revs-file .nonstandard-ignore-revs-file

Author Licenses

You can include OSS licensing information for each author via a .csv file. The author-name will be matched to the values shown in the generated authorship report.

licensing.csv

author-name,license-SPDX-id

A list of SPDX license identifiers can be found at spdx.org/licenses

Then tell the CLI about the authorship file (resolved relative to your current working directory)

git-authorship REPO_URL --author-licenses licensing.csv

Pseudonyms

If certain files are being attributed to an unexpected author (e.g. if a contributor copied code from another project, the blame would show the contributor instead of the original author), you can manually override the blame and licensing information.

pseudonyms.csv

target-path,actual-author,license-SPDX-id

A list of SPDX license identifiers can be found at spdx.org/licenses

Then tell the CLI about the pseudonyms file (resolved relative to your current working directory)

git-authorship REPO_URL --pseudonyms pseudonyms.csv

License

Copyright (c) 2022-2024 Joseph Hale, All Rights Reserved

Provided under the terms of the Mozilla Public License, version 2.0

What does the MPL-2.0 license allow/require?

TL;DR

You can use files from this project in both open source and proprietary applications, provided you include the above attribution. However, if you modify any code in this project, or copy blocks of it into your own code, you must publicly share the resulting files (note, not your whole program) under the MPL-2.0. The best way to do this is via a Pull Request back into this project.

If you have any other questions, you may also find Mozilla's official FAQ for the MPL-2.0 license insightful.

If you dislike this license, you can contact me about negotiating a paid contract with different terms.

Disclaimer: This TL;DR is just a summary. All legal questions regarding usage of this project must be handled according to the official terms specified in the LICENSE file.

Why the MPL-2.0 license?

I believe that an open-source software license should ensure that code can be used everywhere.

Strict copyleft licenses, like the GPL family of licenses, fail to fulfill that vision because they only permit code to be used in other GPL-licensed projects. Permissive licenses, like the MIT and Apache licenses, allow code to be used everywhere but fail to prevent proprietary or GPL-licensed projects from limiting access to any improvements they make.

In contrast, the MPL-2.0 license allows code to be used in any software project, while ensuring that any improvements remain available for everyone.

Metadata

Release files for git-authorship 0.5.1

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

Source distribution (sdist)

Source distribution for git-authorship 0.5.1
File Size Uploaded Provenance Actions
git_authorship-0.5.1.tar.gz 16.8 kB Without provenance Details for git_authorship-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for git-authorship 0.5.1
File Interpreter ABI Platform Actions
git_authorship-0.5.1-py3-none-any.whl Python 3 none any Details for git_authorship-0.5.1-py3-none-any.whl

Total release size: 34.9 kB

Release files / git_authorship-0.5.1.tar.gz

Download URL git_authorship-0.5.1.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9c5b8fac1950fcb1126089f0ec33f5516dbeeb0d040f798f4ea327ecf37adf10
BLAKE2b-256 checksum
How to use checksums
ea2b5f0ef1d15c37b4d597731f7b23d3957f660fa75b8e2479352a2413411b70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.18 Linux/5.15.167.4-microsoft-standard-WSL2

Release files / git_authorship-0.5.1-py3-none-any.whl

Download URL git_authorship-0.5.1-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6774d3ff4f80294721bc54c3084dd2166cd3e51383b49d77af32e797b27e6dd5
BLAKE2b-256 checksum
How to use checksums
479e8bb3db5d3218e4fc85da8d318b60eac6c87e86355c9bed4c1fdf63714a69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.8.18 Linux/5.15.167.4-microsoft-standard-WSL2

Security for git-authorship 0.5.1

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