Metadata-Version: 2.1
Name: cov-change
Version: 0.1.2
Summary: 
Author: vsingh18567
Author-email: vsingh18567@gmail.com
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: rich (>=13.6.0,<14.0.0)
Description-Content-Type: text/markdown

# Cov Change
Cov change is a tool to help you find the changes in your code that are not covered by your tests. It uses `git diff` to find your changes, and `coverage` to find your test coverage.

## Installation
```bash
pip install cov-change
```

## Usage
Assuming you've already run `pytest` with `coverage` (e.g. `coverage run pytest .`), you will have generated a `.coverage` file. To then use `cov-change`:

```bash
coverage json # generate a json file from the .coverage file
cov-change
```
By default, `cov-change` will compare your current branch to `origin/main`. The full usage is:

```bash
cov-change [diff_branch] [curr_branch] [--coverage-file COVERAGE_FILE]  [-o --output OUTPUT] [-v --verbose] [--diff-file DIFF_FILE] [--use-coverage-diff] [-h --help]
```

### Options
- `diff_branch` and `curr_branch` are the branches you want to compare. By default, `diff_branch` is `origin/main` and `curr_branch` is your current commit.
- `--coverage-file COVERAGE_FILE` is the path to the coverage file. By default, it is `coverage.json`.
- - `-o --output OUTPUT` is the path to the output JSON file. By default, it is `coverage_change.json`.
- `-v --verbose` will print out the missing lines for each file.
- `--diff-file DIFF_FILE` is the path to a pre-generated diff file. If this is not passed in, the `git diff` will be run within the `cov-change` command itself. It is recommended that you **do not** pass this argument in.
- `--use-coverage-diff` assumes that `cov-change` has already been run once, and that the coverage change file has been generated. It will then use that diff file to generate the output.

### Examples
```bash
cov-change # compare origin/main to current commit
cov-change origin/dev HEAD # compare origin/dev to the current commit
cov-change origin/dev HEAD --coverage-file my_coverage.json -v # compare origin/dev to the current commit, using my_coverage.json as the coverage file and printing out the missing lines
```

### `cov-change-check`
`cov-change-check` checks if the generated `coverage_change.json` file meets requirements. If it does, it will exit with a non-zero exit code. This is useful for CI/CD pipelines. The full usage is:
```bash
cov-change-check [coverage_change_file] [--total TOTAL] [--file FILE] [-h --help]
```

#### Options
- `coverage_change_file` is the path to the coverage change file. By default, it is `coverage_change.json`.
- `--total TOTAL` is the minimum total coverage change required. By default, it is 0.
- `--file FILE` is the minimum coverage change required in each file. By default, it is 0.

#### Examples
```bash
cov-change-check --total 80 --file 50 # check if the total coverage is at least 80%, and if each file has at least 50% coverage
```

