Skip to content

Commit

Permalink
use commit over add to catch all cases (commit -am)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Nov 11, 2015
1 parent f11327b commit 27ba5cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -3,7 +3,7 @@
Git plugin that helps prevent sensitive data from being committed by sniffing potential commits against regular expressions from a local `.githound.yml` file.

## How does it work?
It runs the output of `git diff -U0` through the Hound, which matches every _added_ or _modified_ line against your provided list of regular expressions. This runs in O(m*n) time (where m is the number of lines and n is the number of patterns), so be sure to commit often. But you should be doing that anyway, right?
Upon commit, it runs the output of `git diff -U0` through the Hound, which matches every _added_ or _modified_ line against your provided list of regular expressions. This runs in O(m*n) time (where m is the number of lines and n is the number of patterns), so be sure to commit often. But you should be doing that anyway, right?

## Installation
To install Hound, please use `go get`. If you don't have Go installed, [get it here](https://golang.org/dl/). If you would like to grab a precompiled binary, head over to the [releases](https://github.com/ezekg/git-hound/releases) page. The precompiled Hound binaries have no external dependencies.
Expand All @@ -12,18 +12,19 @@ To install Hound, please use `go get`. If you don't have Go installed, [get it h
go get github.com/ezekg/git-hound
```

**Alias `git add` inside `~/.bash(rc|_profile)`:** _(optional)_
**Alias `git commit` inside `~/.bash(rc|_profile)`:** _(optional)_
```bash
alias git='_() { if [[ "$1" == "add" ]]; then git-hound "$@"; else git "$@"; fi }; _'
alias git='_() { if [[ "$1" == "commit" ]]; then git-hound "$@"; else git "$@"; fi }; _'
```

## Usage
```bash
git hound add <files>
git add <files> # When using the optional alias above
git hound commit ...
git commit ... # When using the optional alias above
```

## Option flags
These flags should be included inside of the `git` alias, if used.

| Flag | Type | Default | Usage |
| :------------- | :----- | :-------------- | :----------------------------------------- |
Expand Down
3 changes: 1 addition & 2 deletions main.go
Expand Up @@ -22,8 +22,6 @@ func main() {
hound := &Hound{Config: *config}
git := &Command{Bin: *bin}

out, code := git.Exec(flag.Args()...)

if _, ok := hound.New(); ok {
out, _ := git.Exec("diff", "-U0", "--staged")
fileDiffs, err := diff.ParseMultiFileDiff([]byte(out))
Expand All @@ -46,6 +44,7 @@ func main() {
}
}

out, code := git.Exec(flag.Args()...)
fmt.Print(out)
os.Exit(code)
}

0 comments on commit 27ba5cb

Please sign in to comment.