Investigate a Git repository's revision history to find text patterns.
Project description
Poirot helps you investigate your repositories. Give him a set of clues (e.g. strings or regular expressions) and he will report back any instances they have occurred in your repository’s revision history.
When used as a pre-commit hook, Poirot can warn you if you’re about to commit something you might not intend (think passwords, private keys, tokens, and other bits of sensitive or personally identifiable information).
Poirot began as a fork of CFPB’s fellow gumshoe, Clouseau.
Dependencies
git
Python 2.7 or 3.3+
a Unix-based OS (e.g. Mac or Linux) or a UNIX-y shell on Windows (e.g. Cygwin, Babun, or Git-Bash)
Poirot uses these Python packages:
Running Poirot
To invoke Poirot and see his findings, call him from the command line with big-grey-cells
(for wordy, colorful output) or little-grey-cells
(for minimalistic output) and with the following optional arguments:
–url: The repository’s URL, e.g.
https://github.com/DCgov/poirot.git
orgit@github.com:DCgov/poirot.git
. When included, you will be given the choice to clone or pull from the remote URL. Default value: none.–dir: The local path to your repository’s base directory or the directory you would like to clone or pull to. Default value: the current working directory.
–term: A single term or regular expression to search for. Default value: none.
–patterns: The path to a .txt file with strings or regular expression patterns, each on its own line. You can give a comma-separated list of pattern files, if you wish to include more than one. Default value: none.
–staged: A flag, which when included, restricts search to staged revisions. This is helpful, along with
--dir
, as part of a pre-commit hook.–revlist: A range of revisions to inspect. Default value: The last commit (i.e.
HEAD^!
) if--staged
is not included, otherwise none.–before: Date restriction on revisions. Default value: none.
–after: Date restriction on revisions. Default value: none.
–author: Authorship restriction on revisions. Default value: none.
Examples
Note: in all of the following examples, big-grey-cells
could be substituted for little-grey-cells
.
The most basic command Poirot will accept is:
big-grey-cells
That will search the current git directory’s last commit (i.e. HEAD^!
) for the patterns in the default pattern file. thisisaterm
.
To specify one or more different patterns files, do this instead:
big-grey-cells --patterns='thisisapatternfile.txt'
Or for a single term (like thisisaterm
):
big-grey-cells --term="thisisaterm"
Say you want to search for thisisaterm
in the whole revision history of the current branch. Then do:
big-grey-cells --term="thisisaterm" --revlist="all"
You can further restrict the set of revisions Poirot looks through with the before
, after
, and author
options (which correspond to the same flags in git). E.g.:
big-grey-cells --term="thisisaterm" --revlist=40dc6d1...3e4c011 --before="2015-11-28" --after="2015-10-01" --author="me@poirot.com"
Perhaps you don’t have the repository available locally or you would like to update it from a remote URL. Just add the url
to your command and it will allow you to clone or pull:
big-grey-cells --url https://github.com/foo/baz.git --term="thisisaterm"
You can also specify a different directory than the current one with dir
. The following command will clone/pull to the folder thisotherfolder
, which sits inside of the current directory. If it does not yet exist, it will be created.
big-grey-cells --url https://github.com/foo/baz.git --term="thisisaterm" --dir="thisotherfolder"
To search changes that have been staged for commit, but not yet committed, use the staged
flag:
big-grey-cells --term="thisisaterm" --staged
Project details
Release history Release notifications | RSS feed
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
Hashes for poirot-0.0.19-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ed60a0a2233351ade9f388c12062a926198917aa74fc9df05f81a0c6ed9990d |
|
MD5 | f7a42d3ed73002cd72075bdcc150d87c |
|
BLAKE2b-256 | d08a9e0897ad92ffc1a2667733d3fb379625beef4ee3f6584de762cc737250c4 |