[chore] - update docs for pre-commit (#2280)

* update docs for pre-commit

* fix spacing
This commit is contained in:
ahrav 2024-01-09 15:41:27 -08:00 committed by GitHub
parent 24a09bc37d
commit b2c0d50ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -421,6 +421,12 @@ If you'd like to specify specific `base` and `head` refs, you can use the `base`
## Pre-commit Hook
Trufflehog can be used in a pre-commit hook to prevent credentials from leaking before they ever leave your computer.
**Key Usage Note:**
- **For optimal hook efficacy, execute `git add` followed by `git commit` separately.** This ensures Trufflehog analyzes all intended changes.
- **Avoid using `git commit -am`, as it might bypass pre-commit hook execution for unstaged modifications.**
An example `.pre-commit-config.yaml` is provided (see [pre-commit.com](https://pre-commit.com/) for installation).
```yaml

View file

@ -120,7 +120,7 @@ func NormalizeOrgRepoURL(provider provider, repoURL string) (string, error) {
func GenerateLink(repo, commit, file string, line int64) string {
// Some paths contain '%' which breaks |url.Parse| if not encoded.
// https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding
file = strings.Replace(file, "%", "%25", -1)
file = strings.ReplaceAll(file, "%", "%25")
switch determineProvider(repo) {
case providerBitbucket:
@ -140,7 +140,7 @@ func GenerateLink(repo, commit, file string, line int64) string {
default:
var baseLink string
//Gist links are formatted differently
// Gist links are formatted differently
if strings.HasPrefix(repo, "https://gist.github.com") {
baseLink = repo[:len(repo)-4] + "/"
if commit != "" {