copywrite icon indicating copy to clipboard operation
copywrite copied to clipboard

Pre-commit installation fails

Open sgabenov opened this issue 1 year ago • 4 comments

It seems like, if i use this tool with pre-commit, it tries to search Go files not in pre-commit .cache directory, but from root path of the repo. Could you please check with some empty git repo to use this pre-commit configuration to get same errors.

After creating .pre-commit-config.yaml and commiting files \ executing pre-commit run

repos:
- repo: https://github.com/hashicorp/copywrite
  rev: v0.16.4
  hooks:
    - id: add-headers
    - id: check-headers

have such error:

Add copyright headers....................................................Failed
- hook id: add-headers
- exit code: 1
go: cannot find main module, but found .git/config in /Users/gabenov/git/sandbox/pre-commit
	to create a module there, run:
	go mod init

or after executing go mod init pre-commit

Validate copyright headers...............................................Failed
- hook id: check-headers
- exit code: 1
no Go files in /Users/gabenov/git/sandbox/pre-commit

version: pre-commit 3.3.2

sgabenov avatar Jul 11 '23 11:07 sgabenov

Getting the same error. I do have Go installed, but I'm using it in .NET project (with some Terraform).

I installed the tool using homebrew, so I was expecting the pre-commit-hooks to run the installed binary instead of doing go run.

bloudraak avatar Jul 23 '23 02:07 bloudraak

Hey folks!

Before I jump into troubleshooting, it sounds like there may be some ergonomics issues with using the Golang-mechanism for installation. To make things more idiomatic with how you would expect pre-commit hooks to work, would it be preferable to have the hook install the binary from GitHub releases or expect it to already be in the user's $PATH?

CalebAlbers avatar Jul 23 '23 03:07 CalebAlbers

I expected it to use the copy I installed. That being said, it would be preferable if the hook installed the binary, so it can work on any supported platform, including Windows (which some teammates use).

bloudraak avatar Jul 23 '23 04:07 bloudraak

I think, that pre-hook should not install golang itself. The better is to distribute 'copywrite' as a prebuild binary, as it said, it could be executed on each platform.

sgabenov avatar Aug 09 '23 07:08 sgabenov