A few more updates. Added new flags to usage.

This commit is contained in:
Elf M. Sternberg 2016-09-22 15:50:01 -07:00
parent 0ec3a446ba
commit 904eb24281
3 changed files with 64 additions and 35 deletions

7
docs/modules.rst Normal file
View File

@ -0,0 +1,7 @@
git_lint
========
.. toctree::
:maxdepth: 4
git_lint

View File

@ -11,42 +11,42 @@ git lint [options] [filenames]
Options
-------
``-h`` ``--help``
Help
``-v`` ``--version``
Version info
``-c`` ``--config``
Specify config file (default: ``$GIT_DIR/.git-lint``)
``-w`` ``--workspace``
Check workspace [default]
``-s`` ``--staging``
Check files in the staging area (useful as a pre-commit hook)
``-b`` ``--base``
Run checks from your repository's root directory. By default,
``git-lint`` only runs from the current working directory.
``-a`` ``--all``
Check all files in repository from the current directory, not
just changed files
``-e`` ``--everything``
An alias for ``-b -a``, checks every file in the repository
``-o`` ``--only``
Run only specific linters, skipping all others
``-e`` ``--exclude``
Exclude specific linters, running all others
A comma-separated list of only those linters to run
``-x`` ``--exclude``
A comma-separated list of linters to skip
``-l`` ``--linters``
Show the list of configured linters
``-b`` ``--base``
Check all changed files in the repository, not just those in the current directory.
``-a`` ``--all``
Scan all files in the repository, not just those that have changed.
``-e`` ``--every``
Short for -b -a: scan everything
``-w`` ``--workspace``
Scan the workspace
``-s`` ``--staging``
Scan the staging area (useful for pre-commit).
``-g`` ``--changes``
Report lint failures only for diff'd sections
``-p`` ``--complete``
Report lint failures for all files
``-c`` ``--config``
Path to config file
``-d`` ``--dryrun``
Report what git-lint would do, but don't actually do anything.
``-q`` ``--quiet``
Produce a short report of files that failed to pass.
``-h`` ``--help``
This help message
``-v`` ``--version``
Version information
As a pre-commit hook:
---------------------
.. code-block:: python
#!/usr/bin/env python
import git_lint
git_lint.run_precommit(staging = True, timestamps = True)
@ -54,6 +54,8 @@ As a pre-commit hook:
Install this file in your project's ``.git/hooks/pre-commit``, and set
the file's executable flag to ``true``:
.. code-block:: shell
chmod +x pre-commit
Please see the :ref:`api` for more details on options taken by the

View File

@ -37,10 +37,6 @@
(defn split-git-response [cmd]
(let [[(, out error returncode) (get-git-response-raw cmd)]] (.splitlines out)))
(defn split-git-response [cmd]
(let [[(, out error returncode) (get-git-response-raw cmd)]] (.splitlines out)))
(defn run-git-command [cmd]
(let [[fullcmd (+ ["git"] cmd)]]
(subprocess.call fullcmd
@ -67,6 +63,30 @@
[(, out err returncode) (get-git-response-raw ["rev-parse" "--verify HEAD"])]]
(if (not err) "HEAD" empty-repository-hash)))
(defn run-external-checker [filename check]
(let [[cmd (-> (get check "command")
(.format
:filename filename
:config_path *config-path*))]
[(, out err returncode) (get-shell-response cmd)]]
(if (or (and out (= (.get check "error_condition" "error") "output"))
err
(not (= returncode 0)))
(let [[prefix (if (get check "print_filename")
(.format "\t{}:" filename)
"\t")]
[output (+ (encode-shell-messages prefix out)
(if err (encode-shell-messages prefix err) []))]]
[(or returncode 1) output])
[0 []])))
; ___ _ _ ___ _ _ ___ _ _
;| __(_) |___ _ _ __ _ _ __ ___ | __|_ _| |_ ___ _ _ __(_)___ _ _ / __| |_ ___ __| |__
;| _|| | / -_) ' \/ _` | ' \/ -_) | _|\ \ / _/ -_) ' \(_-< / _ \ ' \ | (__| ' \/ -_) _| / /
;|_| |_|_\___|_||_\__,_|_|_|_\___| |___/_\_\\__\___|_||_/__/_\___/_||_| \___|_||_\___\__|_\_\
;
(defn make-match-filter-matcher [extensions]
(->> (map (fn [s] (.split s ",")) extensions)
(reduce operator.add)