Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jan 9, 2024
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/giturl/giturl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 != "" {
Expand Down
Loading