hydra icon indicating copy to clipboard operation
hydra copied to clipboard

scmdiff: Hardcode `--git-dir`

Open knedlsepp opened this issue 2 years ago • 3 comments

The newest version of git refuses to work on repositories not owned by the current user. This leads to issues with the /api/scmdiff endpoint:

May 27 11:16:05 myhydra hydra-server[923698]: fatal: unsafe repository ('/var/lib/hydra/scm/git/57ea036ec7ecd85c8dd085e02ecc6f12dd5c079a6203d16aea49f586cadfb2be' is owned by someone else)
May 27 11:16:05 myhydra hydra-server[923698]: To add an exception for this directory, call:
May 27 11:16:05 myhydra hydra-server[923698]:         git config --global --add safe.directory /var/lib/hydra/scm/git/57ea036ec7ecd85c8dd085e02ecc6f12dd5c079a6203d16aea49f586cadfb2be
May 27 11:16:05 myhydra hydra-server[923701]: warning: Not a git repository. Use --no-index to compare two paths outside a working tree
May 27 11:16:05 myhydra hydra-server[923701]: usage: git diff --no-index [<options>] <path> <path>

I used the same solution that was used in NixOS/nix#6440.

Fixes #1214

knedlsepp avatar May 27 '22 09:05 knedlsepp

Thanks for looking into this! Will apply locally to see if that fixes the issue for latest nixpkgs unstable as well.

Mindavi avatar May 29 '22 21:05 Mindavi

I forgot to report back, this fixes the issue for me.

Mindavi avatar Jun 07 '22 19:06 Mindavi

Can you maybe write a test for this? I think this would probably fit into t/Hydra/Controller/API/checks.t.

ajs124 avatar Jun 08 '22 21:06 ajs124

But the test…

dasJ avatar Nov 25 '22 11:11 dasJ

But the test…

I'm sorry about that. I tried to write one, but I couldn't make it work. 😕

knedlsepp avatar Nov 26 '22 07:11 knedlsepp