A python package for making stacked area plots of contributions over time.
Project description
Contrib
A python package for making stacked area plots of contributions to a git repository over time. Plots can show contributions by authors, or by organizations.
Installation
contrib
is on PyPI, so you can just pip install
it:
$ pip install contrib
Alternately, you can clone this project, add its directory to your
PYTHONPATH
, and add the bin
directory to your PATH
.
Usage
To use contrib
, you'll need to create a configuration file telling it
where to find your code. Below is an example for Spack; you can find
complete code in the
spack-contributions repo.
Here's an example contrib.yaml
:
contrib:
# Path to your git repository. to run git blame on.
# Consider making this a git submodule.
repo: ./spack
# JSON file mapping authors to organizations (optional)
orgmap: ./author-to-org.json
# Separate parts of the repository to process (optional). For each
# commit, contrib will look for files that match the patterns in each
# part. For a simple repo, you may only need one regular expression
# per part. In Spack, the packages have moved around in the repo over
# time, so we provide multiple patterns. Contrib will use the first
# pattern matched by any file in each commit.
parts:
packages:
- ^var/spack/repos/builtin/packages/.*\.py$
- ^var/spack/packages/.*\.py$
- ^lib/spack/spack/packages/.*\.py$
The repo
needs to be in your local filesystem, preferably in the same
directory as contrib.yaml
. orgmap
is optional (see below for how to
generate it). parts
is also optional; if you do not specify it, there
will be one part called all
that matches everything:
parts:
all:
- ^.*$
You can name your parts anything; see the example above for how to model a repository where different logical parts have moved around in subdirectories.
Mapping authors to organizations
The orgmap
(author-to-org.json
in the example above) is optional. If
you choose to provide it, it should be simple json
dictionary mapping
authors to organizations:
{
"Author 1": "UIUC",
"Author 2": "LBL",
...
"Author N": "LLNL"
}
You can run contrib --update-org-map
to generate an orgmap
to start
with. contrib
will look at your repository's history and generate the
file automatically:
$ contrib --update-org-map
==> Added 503 new authors to 'author-to-org.json'
==> New orgmap file created in 'author-to-org.json'.
==> Add it to './contrib.yaml' like this:
contrib:
orgmap: author-to-org.json
If you then add this file to your contrib.yaml
, you can update it later
as your repository evolves:
$ contrib --update-org-map
==> Added 10 new authors to 'author-to-org.json'
Newly added authors will be labeled as unknown <email from git>
in the
json
file:
"Author 1": "unknown <foo@bar.com>",
"Author 2": "unknown <444532+someusername@users.noreply.github.com>",
"Author 3": "unknown <user@example.com>",
You can replace these with valid organizations, or just leave them and
they'll show up as "unknown" in the contrib
plots.
Running
Once you've got all of that set up, you can run contrib
in the
directory where contrib.yaml
lives:
$ ls
author-to-org.json contrib.yaml
$ contrib
==> Indexing 49 commits.
STARTED 0/49 53ab298e88f80454f7f7c20ef200a3dbd0870473
packages: processed 45/3487 blames (9.04/s)
...
By default, contrib
will sample 50 commits from your repository and
plot them. If you want it to plot fewer samples, you can run contrib --samples SAMPLES
where SAMPLES
is a number of your choosing.
contrib
tries to use the available processors on the machine it is
run, and by default it will run parallel git blame
jobs. You can
control the parallelism with the --jobs JOBS
argument.
contrib
has to run git blame
for each sampled commit and for each
file matched by the parts
section of your contrib.yaml
file (or for
all files if parts
is not provided), so it can take a long time to run
if your repo's history is long. contrib
's output shows how many git blame
calls remain and how fast blames are currently completing.
Cached data
contrib
caches results of git blame
in a directory called
line-data
. For large repositories, this can get to be quite large, so
make sure you have a decent amount of space available (gigabytes for
large repositories).
License
Contrib is part of the Spack project. Spack is distributed under the terms of both the MIT license and the Apache License (Version 2.0). Users may choose either license, at their option.
All new contributions must be made under both the MIT and Apache-2.0 licenses.
See LICENSE-MIT, LICENSE-APACHE, COPYRIGHT, and NOTICE for details.
SPDX-License-Identifier: (Apache-2.0 OR MIT)
LLNL-CODE-647188
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
Built Distribution
File details
Details for the file contrib-0.3.0.tar.gz
.
File metadata
- Download URL: contrib-0.3.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.36.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55cf3a414c8b136f58588ec02e6833d1cc1d227a78f1778354ac6fcf9c2ccdda |
|
MD5 | c43e2594f221d6276b453d94ee894485 |
|
BLAKE2b-256 | 9c746ae5c7253c958bf6678ea3d8ce049361ae097ea9164ceed3572a32fd5762 |
File details
Details for the file contrib-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: contrib-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.36.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be9e35bc15b9e73b2c40ab94b0f20695ac1af5f2792610c959f64db4de438e91 |
|
MD5 | a4774bea8b009df737fd92323153d7ee |
|
BLAKE2b-256 | 8f7d62e5220e638d2b0defd9d5fd52c70cb89e372519d7941dd5cc7924b8c7b9 |