Gitmit
This is a library for finding the commit times of all the files under a git repository.
Can be used from the commandline:
$ cd /some/repository $ gitmit
Or as a library:
from gitmit.mit import GitTimes print(GitTimes(root_folder, ".").find())
Options to both include:
- parent_dir
The relative folder to the root of the repository that we care about. The rest of the filters are then relative to here.
- timestamps_for
A list of globs specifying what to include (i.e. anything not covered by the globs is ignored)
- exclude
A list of globs specifying what to exclude after timestamps_for is taken into account
- include
A list of globs specifying what should be re-included after exclude is taken into account
- with_cache
Boolean saying whether we should write the resulting commit times to a file under the .git folder that we can reuse in the future.
- debug
Currently the only difference with debug is outputting the commits per second as we traverse the commits in the repository.
Why/History
I needed this ability in my Docker client (http://harpoon.readthedocs.org) so that I could maintain the modified times of the files in the context sent to the docker daemon between builds on my build servers (doing a git clone sets the modified times of the files to the time of the clone).
Originally I was shelling out to git log for every file. This was slow! I then moved to dulwich (python implementation of git) which was faster, but still slow. Then I implemented it with pygit2 (libgit2 c bindings in python) and decided to make it a separate library.
Unfortunately it’s still not as fast as doing a git whatchanged --pretty=%at and interpreting the results, but I rather a solution that uses libraries rather than interpreting text from the output of a program and the speed is not a problem for reasonably sized repositories.
In September 2018 I moved back to using dulwich. This is because pygit2 is a bit of a pain because of how it pins to particular versions of libgit2, which itself can be annoying to get installed such that pygit2 can find it.
Installation
Just use pip:
$ pip install gitmit
Changelog
- 0.5 - TBD
Switch to dulwich over pygit2. This is because pygit2 is a pain to install. The downside is it is slower, but only by a few seconds.
Before 0.5 no changelog was maintained
Tests
Install testing deps and run the helpful script:
$ pip install -e . $ pip install -e ".[tests]" $ ./test.sh
Or use tox:
$ pip install tox $ tox
Metadata
Release files for gitmit 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gitmit-0.5.tar.gz | 11.1 kB | Details |
Release files / gitmit-0.5.tar.gz
| Download URL | gitmit-0.5.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4b6ef3734cc1fe5b5d26cb44f9135bbc548553e18f1f53e30282d5afcdf7145
|
|
BLAKE2b-256 checksum How to use checksums |
4a1c235c8e310fc485e9400f427b2ed69fa9ca2d560cf413a1defe49e4fae93d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.1 CPython/2.7.14
|