github.com/lubgr/revgrep@v0.0.0-20240125154757-7e5ee1900f8a/README.md (about)

     1  # Overview
     2  
     3  [![Build Status](https://travis-ci.org/bradleyfalzon/revgrep.svg?branch=master)](https://travis-ci.org/bradleyfalzon/revgrep) [![Coverage
     4  Status](https://coveralls.io/repos/github/bradleyfalzon/revgrep/badge.svg?branch=master)](https://coveralls.io/github/bradleyfalzon/revgrep?branch=master) [![GoDoc](https://godoc.org/github.com/bradleyfalzon/revgrep?status.svg)](https://godoc.org/github.com/bradleyfalzon/revgrep)
     5  
     6  `revgrep` is a CLI tool used to filter static analysis tools to only lines changed based on a commit reference.
     7  
     8  # Install
     9  
    10  ```bash
    11  go get -u github.com/bradleyfalzon/revgrep/...
    12  ```
    13  
    14  # Usage
    15  
    16  In the scenario below, a change was made causing a warning in `go vet` on line 5, but `go vet` will show all warnings.
    17  Using `revgrep`, you can show only warnings for lines of code that have been changed (in this case, hiding line 6).
    18  
    19  ```bash
    20  [user@host dir (master)]$ go vet
    21  main.go:5: missing argument for Sprintf("%s"): format reads arg 1, have only 0 args
    22  main.go:6: missing argument for Sprintf("%s"): format reads arg 1, have only 0 args
    23  [user@host dir (master)]$ go vet |& revgrep
    24  main.go:5: missing argument for Sprintf("%s"): format reads arg 1, have only 0 args
    25  ```
    26  
    27  `|&` is shown above as many static analysis programs write to `stderr`, not `stdout`, `|&` combines both `stderr` and
    28  `stdout`. It could also be achieved with `go vet 2>&1 | revgrep`.
    29  
    30  `revgrep` CLI tool will return an exit status of 1 if any issues match, else it will return 0. Consider using
    31  `${PIPESTATUS[0]}` for the exit status of the `go vet` command in the above example.
    32  
    33  ```
    34  Usage: revgrep [options] [from-rev] [to-rev]
    35  
    36  from-rev filters issues to lines changed since (and including) this revision
    37    to-rev filters issues to lines changed since (and including) this revision, requires <from-rev>
    38  
    39    If no revisions are given, and there are unstaged changes or untracked files, only those changes are shown
    40    If no revisions are given, and there are no unstaged changes or untracked files, only changes in HEAD~ are shown
    41    If from-rev is given and to-rev is not, only changes between from-rev and HEAD are shown.
    42  
    43      -d    Show debug output
    44        -regexp string
    45                Regexp to match path, line number, optional column number, and message
    46  ```
    47  
    48  # Other Examples
    49  
    50  Issues between branches:
    51  ```bash
    52  [user@host dir (feature/branch)]$ go vet |& revgrep master
    53  ```
    54  
    55  Issues since last push:
    56  ```bash
    57  [user@host dir (master)]$ go vet |& revgrep origin/master
    58  ```