Home > front end >  Creating git-hooks for pre-commit using ggshield
Creating git-hooks for pre-commit using ggshield

Time:01-12

I have a android project and want to install a pre-commit.

I was following this example: https://docs.gitguardian.com/internal-repositories-monitoring/integrations/git_hooks/pre_commit

repos:
  - repo: https://github.com/gitguardian/ggshield
    rev: main
    hooks:
      - id: ggshield
        language_version: python3
        stages: [commit]

I have also done the following:

pre-commit autoupdate
Updating https://github.com/gitguardian/ggshield ... already up to date.

However, when I try and make a commit I get the following error messages:

git commit -am"Updated pre-commit file"
GitGuardian Shield (pre-commit)..........................................Failed
- hook id: ggshield
- exit code: 1

Traceback (most recent call last):
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/bin/ggshield", line 8, in <module>
    sys.exit(cli_wrapper())
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/ggshield/cmd.py", line 229, in cli_wrapper
    return_code: int = cli.main(standalone_mode=False)
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/click/core.py", line 1656, in invoke
    super().invoke(ctx)
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/ggshield/cmd.py", line 121, in scan
    ctx.obj["client"] = retrieve_client(ctx)
  File "/home/steve/.cache/pre-commit/repol8_kb04j/py_env-python3/lib/python3.9/site-packages/ggshield/utils.py", line 248, in retrieve_client
    raise click.ClickException("GitGuardian API Key is needed.")
click.exceptions.ClickException: GitGuardian API Key is needed.

CodePudding user response:

you must set up a gitguardian api key to use their service (it isn't a freely available public service). the git hook and cli are a thin wrapper around the GitGuardian api

  •  Tags:  
  • Related