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

Error running ggshield in Docker within a Git worktree #977

Open
alikeys-nable opened this issue Oct 9, 2024 · 0 comments
Open

Error running ggshield in Docker within a Git worktree #977

alikeys-nable opened this issue Oct 9, 2024 · 0 comments
Labels
status:new This issue needs to be reviewed type:bug Something isn't working

Comments

@alikeys-nable
Copy link

alikeys-nable commented Oct 9, 2024

Environment

  • ggshield version: latest
  • Operating system (Linux, macOS, Windows): WSL2 within Windows
  • Operating system version: Windows 11
  • Python version:

Describe the bug

I am using a Git worktree. When I commit to the initial worktree directory, the pre-commit check passes. When committing to another Git worktree directory, the path doesn't resolve and there's a message saying it's not a git repository.

Steps to reproduce:

  1. clone a Git repository locally
  2. add another branch from the same repository as a Git worktree: git worktree add ../other-branch-dir feature/my_other_branch
  3. Run ggshield secret scan pre-commit
  4. An error occurs

Actual result:

git commit -m "TESTING COMMIT IN WORKTREE"
latest: Pulling from someplace/ggshield
Digest: sha256:2eb6blahblah
Status: Image is up to date for quay.io/someplace/ggshield:latest
quay.io/someplace/ggshield:latest
fatal: not a git repository: /code/../original-server-code-dir/worktrees/other-branch-dir
make: *** [.make/tools-ggshield.mk:11: ggshield/pre-commit] Error 128

The make target runs the following using Docker:

	@docker run -i --rm \
		-v .:/code \
		--workdir /code \
		--env-file .env \
		--platform=linux/amd64 \
		$(GGSHIELD_IMAGE) ggshield secret scan pre-commit

Expected result:

The ggshield check passes without error. This is the output when committing from the original folder:

latest: Pulling from someplace/ggshield
Digest: sha256:2eb6blahblah
Status: Image is up to date for quay.io/someplace/ggshield:latest
quay.io/someplace/ggshield:latest

No secrets have been found

[feature/my_original_branch 44blahblah] TEST COMMIT

If applicable, add logs or screenshots to help explain your problem.

@alikeys-nable alikeys-nable added status:new This issue needs to be reviewed type:bug Something isn't working labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:new This issue needs to be reviewed type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant