Skip to content

Enable cloning hooks from a private repository #1377

@jankatins

Description

@jankatins

Summary

Running prek run --all-files with a hook which points to a private repo results in

prek run --all-files
error: Failed to init hooks
  caused by: Failed to initialize repo `https://my-org.visualstudio.com/my-project/_git/my-private-hook-repo`
  caused by: Command `git full clone` exited with an error:

[status]
exit status: 128

[stderr]
fatal: could not read Username for 'https://my-org.visualstudio.com': terminal prompts disabled

Any chance to support such a setup?

pre-commit does allow this, albeit with some manual username/password inputs:

pre-commit run --all-files
[INFO] Initializing environment for https://my-org.visualstudio.com/my-project/_git/my-private-hook-repo.
Username for 'https://my-org.visualstudio.com': my-org
Password for 'https://my-org@my-org.visualstudio.com': <pasted my azure devops token>
[INFO] Installing environment for https://my-org.visualstudio.com/my-project/_git/my-private-hook-repo.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[... regular output... ]

Username is (as far as I remember) an arbitrary string (I set it to my org name), the password was my azure devops token which is allowed to read the repos.

Platform

Linux 6.18.4-200.fc43.x86_64 x86_64 GNU/Linux

Version

prek 0.2.28

.pre-commit-config.yaml

repos:
  - repo: https://github.com/crate-ci/typos
    rev: v1.42.0
    hooks:
      - id: typos
  - [...]
  - repo: https://my-org.visualstudio.com/my-project/_git/my-private-hook-repo
    rev: 2ea1363754318f7622b0c54be21112bcdbe7f2ff
    hooks:
      - id: fix-grafana-alerts

Log file

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions