Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

---
repos:
- repo: https://github.com/hashicorp/copywrite
rev: v0.15.0 # Use any release tag
hooks:
- id: copywrite-headers
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
Expand Down
27 changes: 27 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- id: add-headers
name: Add copyright headers
description: Adds missing copyright headers to all source code files
entry: go run .
language: golang
args: [headers]

- id: check-headers
name: Validate copyright headers
description: Checks if any copyright headers are missing, but does not make changes
entry: go run .
language: golang
args: [headers --plan]

- id: add-license
name: Add or fix repo license
description: Adds or updates a non-compliant LICENSE file
entry: go run .
language: golang
args: [license]

- id: check-license
name: Validate repo license
description: Checks if a LICENSE file is valid, but does not make changes
entry: go run .
language: golang
args: [license --plan]
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ freely in later steps.

:bulb: Running the copywrite command with the `--plan` flag will return a non-zero exit code if the repo is out of compliance.

## Pre-Commit Hooks

Copywrite can be used as a [Pre-Commit](https://pre-commit.com) Hook for those
looking to add copyright headers during local development. A list of supported
hooks can be found in [here](./.pre-commit-hooks.yaml), but the most common use
case for adding missing copyright headers can be done by adding the following
snippet to your repo's `.pre-commit-config.yaml`:

```yaml
- repo: https://github.com/hashicorp/copywrite
rev: v0.15.0 # Use any release tag
hooks:
- id: copywrite-headers
```

## Debugging

Copywrite supports several built-in features to aid with debugging. The first
Expand All @@ -171,14 +186,11 @@ itself in. The `copywrite debug` command can print the running configuration,
whether or not a config file was loaded, what GitHub auth type is in use, and
more. No sensitive information is printed, however.

## Development

### IDE Settings
## Development

To maintain a consistent developer experience, this repo comes bundled with VS Code settings. When opening the repo for the first time, you will be asked if you want to install [suggested extensions](./.vscode/extensions.json) and your workspace will be pre-configured with consistent format-on-save [settings](./.vscode/settings.json).

### Pre-Commit Hooks

Before committing code, this repo has been setup to check Go files using [pre-commit git hooks](https://pre-commit.com/). To leverage pre-commit, developers must install pre-commit and associated tools locally:

```bash
Expand Down