CommitFence
Esc
↑ ↓ to moveEnter to open
Reference / Commands

Commands

Every command of the command line, with the output of a real run.

On this page

Usage#

Every command, as commitfence --help prints it:

Terminal
$ commitfence --helpUsage:  commitfence --help  commitfence --version  commitfence install [--print] [--no-path]  commitfence init  commitfence catalog [<language> [<artifact type>]]  commitfence rules list  commitfence rules show <id>  commitfence rules enable <id>  commitfence rules disable <id>  commitfence rules severity <id> block|warn  commitfence rules add <id> --for <type> --title <text> [--language <id>] [--severity block|warn] [--where <property=value>]... (--require <property=value>... | --forbid) [--paths <a,b>] [--message <text>] [--why <text>] [--before <id>]  commitfence rules set <id> [--for <type>] [--title <text>] [--where <property=value>... | --no-where] [--require <property=value>... | --forbid] [--paths <a,b> | --no-paths] [--message <text> | --no-message] [--why <text> | --no-why]  commitfence rules copy <id> <new id>    (a copy right after the rule, titled Copy of its title)  commitfence rules remove <id>  commitfence rules try <id> [<file>]    (standard input without a file)  commitfence review --files <path>...  commitfence review --staged  commitfence review --hook pre-push <remote name> <remote url>  commitfence review --push    (what a push of the current branch would send, as the pre-push hook is told)  commitfence review --base <revision> [--head <revision>]  commitfence review --all [<folder or project file>]rules list and rules show also cover the rules that .editorconfig sets; the product never changes that file.Every rules command takes [--settings <path>]; review takes [--settings <path>].exit code 0

install#

Sets the program up for your user. See Installation.

Terminal
$ commitfence install --printWould set the git setting commitfence.path to Q:/CommitFence/commitfence.exe.Would add Q:\CommitFence to your PATH, for programs started after that.exit code 0

init#

Starts commitfence.json in a repository and prints the hook line.

Terminal
$ commitfence initWrote <repository>/commitfence.json, with no rules yet. Add rules with commitfence rules add.Add this line as the first command of the pre-push hook (with husky, the file .husky/pre-push):"$(git config --get commitfence.path)" review --hook pre-push "$@" || exit $?exit code 0

catalog#

commitfence catalog [<language> [<artifact type>]] lists what a rule can be about and the properties it can look at in each. The full list is the rule catalog. An unknown type is refused, and the answer names the known ones:

Terminal
$ commitfence catalog csharp bogus'bogus' is not an artifact type of csharp. Known types: if-statement, method, class, usage.exit code 3

rules#

Every rules command takes --settings <path>. rules list and rules show also cover the rules .editorconfig sets.

CommandWhat it does
rules listLists the rules
rules show <id>Shows one rule, including a rule .editorconfig sets
rules add <id> --for <type> --title <text> …Writes a team rule: --language, --severity block|warn, --where <property=value> (more than one), --require <property=value> or --forbid, --paths <a,b>, --message, --why, --before <id>
rules set <id> …Changes a rule: the same options, and --no-where, --no-paths, --no-message, --no-why
rules copy <id> <new id>A copy right after the rule, titled Copy of its title
rules remove <id>Removes a team rule
rules enable <id>Switches a rule on
rules disable <id>Switches a rule off
rules severity <id> block|warnChooses whether a rule blocks the push or only warns
rules try <id> [<file>]Runs a rule on a file, or on standard input without a file

Examples of each are in Writing a rule. A rule that does not exist is refused:

Terminal
$ commitfence rules show NOPEThe settings file has no rule 'NOPE'.exit code 3

review#

Reviews code against the rules and prints each finding as file(line,column): error|warning id: message, then a summary. Each form says what it reviews:

CommandWhat it reviews
review --pushWhat a push of the current branch would send, as the pre-push hook is told
review --hook pre-push <remote name> <remote url>What the hook is given by git; this is the form the hook line runs
review --stagedWhat is staged
review --base <revision> [--head <revision>]A range of commits
review --files <path>...The named files. It does not build, so a rule that needs the build is not run, and the review says so
review --all [<folder or project file>]The whole of a folder, as of the last commit

It takes --settings <path> too. A review ends with an exit code.

review --push#

Terminal
$ commitfence review --pushsrc/Shop/Invoice.cs(7,9): error TEAM010: No braces around a single-line ifsrc/Shop/Invoice.cs(5,17): warning CA1822: Member 'IsOverdue' does not access instance data and can be marked as static [Shop, net11.0]src/Shop/Invoice.cs(7,28): error TEAM012: Use IClock, not DateTime.NowShop (net11.0): reviewedrefs/heads/main: 3 changed files. Rule files changed: .editorconfig, commitfence.json. 2 changed files of no known language were not looked at. 1 of 1 files reviewed, 1 of 1 builds checked: 2 blocking, 1 warning.exit code 1

review --staged#

Terminal
$ commitfence review --stagedShop (net11.0): reviewedstaged changes: 1 changed file. 1 of 1 files reviewed, 1 of 1 builds checked: 0 blocking, 0 warning.exit code 0

review --files#

Terminal
$ commitfence review --files src/Shop/Invoice.cssrc/Shop/Invoice.cs(7,9): error TEAM010: No braces around a single-line ifnot run: TEAM012 was not run: it needs what the compiler knows about the code, and a review of named files does not build1 of 1 files reviewed: 1 blocking, 0 warning. 1 could not be reviewed, so the review is incomplete. 1 rule needs a build, and a review of named files does not run a build, so it was not run: commitfence review --staged or a push runs it.exit code 1

review --base#

Terminal
$ commitfence review --base HEAD~1src/Shop/Invoice.cs(7,9): error TEAM010: No braces around a single-line ifsrc/Shop/Invoice.cs(5,17): warning CA1822: Member 'IsOverdue' does not access instance data and can be marked as static [Shop, net11.0]src/Shop/Invoice.cs(7,28): error TEAM012: Use IClock, not DateTime.NowShop (net11.0): reviewedHEAD~1..HEAD: 3 changed files. Rule files changed: .editorconfig, commitfence.json. 2 changed files of no known language were not looked at. 1 of 1 files reviewed, 1 of 1 builds checked: 2 blocking, 1 warning.exit code 1

review --all#

Terminal
$ commitfence review --allsrc/Shop/Discount.cs(7,9): error TEAM010: No braces around a single-line ifsrc/Shop/Invoice.cs(7,9): error TEAM010: No braces around a single-line ifsrc/Shop/Invoice.cs(5,17): warning CA1822: Member 'IsOverdue' does not access instance data and can be marked as static [Shop, net11.0]src/Shop/Discount.cs(5,20): warning CA1822: Member 'Apply' does not access instance data and can be marked as static [Shop, net11.0]src/Shop/Invoice.cs(7,28): error TEAM012: Use IClock, not DateTime.NowShop (net11.0): reviewedBy rule: CA1822 2, TEAM010 2, TEAM012 1the whole of the repository at commit b0661c12a5: 6 files. 3 files of no known language were not looked at. 2 of 2 files reviewed, 1 of 1 builds checked: 3 blocking, 2 warning.exit code 1

--version#

commitfence --version prints the version.

Something wrong or unclear on this page? Tell us on GitHub