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 place they appear 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).

Installation

You may want to install it in a virtual environment, unless you plan on using Poirot in a global commit hook.

In that case, you will have to ensure that you have done a global pip install for any Python versions you are using. E.g., if you want to run it on Python 2.7, 3.3, and 3.5 installed, install Poirot as follows:

pip2.7 install poirot
pip3.3 install poirot
pip3.5 install poirot

Running Poirot from the Command Line

To invoke Poirot and see his findings, call him from the command line with poirot and the following optional arguments:

–url: The repository’s URL, e.g. https://github.com/DCgov/poirot.git or git@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. These can be the file’s URL or its relative or absolute local path. You can give a comma-separated list of pattern files, if you wish to include more than one. Default value: default.txt.

–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.

–verbose: A flag to output verbose, colorful output and pattern-match highlighting. The GIF above gives an example with –verbose included.

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 to the current folder.

poirot --url https://github.com/foo/baz.git --term="password"

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.