diff options
| author | Thanos Apollo <public@thanosapollo.org> | 2026-02-05 07:06:15 +0200 |
|---|---|---|
| committer | Nguyễn Gia Phong <cnx@loang.net> | 2026-07-03 16:09:28 +0900 |
| commit | ee71b7003d979953599937b41e65b809e4f0c1fd (patch) | |
| tree | dd381fb83ac0e6852a976304427b1a14c9db880d /gnu | |
| parent | 7e5635caf2d64c8be2706e86db23e3575ee50300 (diff) | |
services: git-http-nginx-location-configuration: Enable configuration of the root URI path /.
* gnu/services/version-control.scm
(git-http-nginx-location-configuration): Handle the case
where uri-path is "/" by not adding an extra slash prefix.
* gnu/tests/version-control.scm (git-nginx-root-configuration):
Generalize from %git-nginx-root-configuration
to take uri-path as an argument from...
(git-http-os): ...this new procedure generalized from %git-http-os
to take uri-path as an argument from...
(git-http-test): ...this new procedure generalized
from run-git-http-test to return a system test
instead of just its store value. Additionally
take name, description, and uri-path arguments.
(%test-git-http): Adjust accordingly.
(%test-git-http-root-path): Duplicate %test-git-http
with "/" instead of "/git/" as uri-path.
Merges: https://codeberg.org/guix/guix/pulls/6140
Co-authored-by: Nguyễn Gia Phong <cnx@loang.net>
Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/services/version-control.scm | 7 | ||||
| -rw-r--r-- | gnu/tests/version-control.scm | 38 |
2 files changed, 31 insertions, 14 deletions
diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm index dba38faa460..55af92c9f5a 100644 --- a/gnu/services/version-control.scm +++ b/gnu/services/version-control.scm | |||
| @@ -275,7 +275,12 @@ access to exported repositories under @file{/srv/git}." | |||
| 275 | (($ <git-http-configuration> package git-root export-all? | 275 | (($ <git-http-configuration> package git-root export-all? |
| 276 | uri-path fcgiwrap-socket) | 276 | uri-path fcgiwrap-socket) |
| 277 | (nginx-location-configuration | 277 | (nginx-location-configuration |
| 278 | (uri (string-append "~ /" (string-trim-both uri-path #\/) "(/.*)")) | 278 | (uri (string-append |
| 279 | "~ " | ||
| 280 | (if (string=? uri-path "/") | ||
| 281 | "" | ||
| 282 | (string-append "/" (string-trim-both uri-path #\/))) | ||
| 283 | "(/.*)")) | ||
| 279 | (body | 284 | (body |
| 280 | (list | 285 | (list |
| 281 | (list "fastcgi_pass " fcgiwrap-socket ";") | 286 | (list "fastcgi_pass " fcgiwrap-socket ";") |
diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm index 9df3aa9dbd4..2a2cc917781 100644 --- a/gnu/tests/version-control.scm +++ b/gnu/tests/version-control.scm | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #:use-module (guix modules) | 39 | #:use-module (guix modules) |
| 40 | #:export (%test-cgit | 40 | #:export (%test-cgit |
| 41 | %test-git-http | 41 | %test-git-http |
| 42 | %test-git-http-root-path | ||
| 42 | %test-gitolite | 43 | %test-gitolite |
| 43 | %test-gitile | 44 | %test-gitile |
| 44 | %test-fossil)) | 45 | %test-fossil)) |
| @@ -217,7 +218,7 @@ HTTP-PORT." | |||
| 217 | ;;; Git server. | 218 | ;;; Git server. |
| 218 | ;;; | 219 | ;;; |
| 219 | 220 | ||
| 220 | (define %git-nginx-configuration | 221 | (define (git-nginx-configuration uri-path) |
| 221 | (nginx-configuration | 222 | (nginx-configuration |
| 222 | (server-blocks | 223 | (server-blocks |
| 223 | (list | 224 | (list |
| @@ -228,19 +229,20 @@ HTTP-PORT." | |||
| 228 | (locations | 229 | (locations |
| 229 | (list (git-http-nginx-location-configuration | 230 | (list (git-http-nginx-location-configuration |
| 230 | (git-http-configuration (export-all? #t) | 231 | (git-http-configuration (export-all? #t) |
| 231 | (uri-path "/git")))))))))) | 232 | (uri-path uri-path)))))))))) |
| 232 | 233 | ||
| 233 | (define %git-http-os | 234 | (define (git-http-os uri-path) |
| 234 | (simple-operating-system | 235 | (simple-operating-system |
| 235 | (service dhcpcd-service-type) | 236 | (service dhcpcd-service-type) |
| 236 | (service fcgiwrap-service-type) | 237 | (service fcgiwrap-service-type) |
| 237 | (service nginx-service-type %git-nginx-configuration) | 238 | (service nginx-service-type (git-nginx-configuration uri-path)) |
| 238 | %test-repository-service)) | 239 | %test-repository-service)) |
| 239 | 240 | ||
| 240 | (define* (run-git-http-test #:optional (http-port 19418)) | 241 | (define* (git-http-test name description uri-path |
| 242 | #:optional (http-port 19418)) | ||
| 241 | (define os | 243 | (define os |
| 242 | (marionette-operating-system | 244 | (marionette-operating-system |
| 243 | %git-http-os | 245 | (git-http-os uri-path) |
| 244 | #:imported-modules '((gnu services herd) | 246 | #:imported-modules '((gnu services herd) |
| 245 | (guix combinators)))) | 247 | (guix combinators)))) |
| 246 | 248 | ||
| @@ -262,7 +264,7 @@ HTTP-PORT." | |||
| 262 | (make-marionette (list #$vm))) | 264 | (make-marionette (list #$vm))) |
| 263 | 265 | ||
| 264 | (test-runner-current (system-test-runner #$output)) | 266 | (test-runner-current (system-test-runner #$output)) |
| 265 | (test-begin "git-http") | 267 | (test-begin #$name) |
| 266 | 268 | ||
| 267 | ;; Wait for nginx to be up and running. | 269 | ;; Wait for nginx to be up and running. |
| 268 | (test-assert "nginx running" | 270 | (test-assert "nginx running" |
| @@ -283,19 +285,29 @@ HTTP-PORT." | |||
| 283 | '#$README-contents | 285 | '#$README-contents |
| 284 | (begin | 286 | (begin |
| 285 | (invoke #$(file-append git "/bin/git") "clone" "-v" | 287 | (invoke #$(file-append git "/bin/git") "clone" "-v" |
| 286 | "http://localhost:8080/git/test" "/tmp/clone") | 288 | #$(simple-format #f "http://localhost:8080~a/test" |
| 289 | (if (string=? uri-path "/") | ||
| 290 | "" | ||
| 291 | (string-append "/" (string-trim-both | ||
| 292 | uri-path #\/)))) | ||
| 293 | "/tmp/clone") | ||
| 287 | (call-with-input-file "/tmp/clone/README" | 294 | (call-with-input-file "/tmp/clone/README" |
| 288 | get-string-all))) | 295 | get-string-all))) |
| 289 | 296 | ||
| 290 | (test-end)))) | 297 | (test-end)))) |
| 291 | 298 | ||
| 292 | (gexp->derivation "git-http" test)) | 299 | (system-test |
| 300 | (name name) | ||
| 301 | (description description) | ||
| 302 | (value (gexp->derivation name test)))) | ||
| 293 | 303 | ||
| 294 | (define %test-git-http | 304 | (define %test-git-http |
| 295 | (system-test | 305 | (git-http-test "git-http" "Connect to a running Git HTTP server." "/git/")) |
| 296 | (name "git-http") | 306 | |
| 297 | (description "Connect to a running Git HTTP server.") | 307 | (define %test-git-http-root-path |
| 298 | (value (run-git-http-test)))) | 308 | (git-http-test "git-http-root-path" |
| 309 | "Connect to a running Git HTTP server with root URI path." | ||
| 310 | "/")) | ||
| 299 | 311 | ||
| 300 | 312 | ||
| 301 | ;;; | 313 | ;;; |
