diff options
| author | Frederick Muriuki Muriithi | 2026-03-06 12:00:06 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-03-06 12:00:06 -0600 |
| commit | 892f38d73a0603d3ee129e8747328d0f27971b60 (patch) | |
| tree | 59f8247d74b1b30859bafe69d5e1753419915f8d | |
| parent | 5501745b7fbf8f5fce46d1cafb8a2197de035c13 (diff) | |
| download | gn-guile-892f38d73a0603d3ee129e8747328d0f27971b60.tar.gz | |
Sync gn-docs from remote.
To ensure we have the latest changes, sync gn-docs before every edit.
| -rw-r--r-- | web/webserver.scm | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/web/webserver.scm b/web/webserver.scm index af27249..60503a4 100644 --- a/web/webserver.scm +++ b/web/webserver.scm @@ -35,11 +35,10 @@ (if dot-pos (substring filename dot-pos) ""))) -(define +current-repo-path+ - (getenv "CURRENT_REPO_PATH")) - -(define +bare-repo-path+ - (getenv "CGIT_REPO_PATH")) +;; Look into moving this into a config file. +(define +current-repo-path+ (getenv "CURRENT_REPO_PATH")) +(define +bare-repo-path+ (getenv "CGIT_REPO_PATH")) +(define +working-branch+ (getenv "GN_GUILE_WORKING_BRANCH")) (define +info+ `(("name" . "GeneNetwork REST API") ("version" . ,get-version) @@ -181,7 +180,7 @@ otherwise search for set/group data" (cons (string->symbol (uri-decode key)) (uri-decode value)))) -(define (edit-file-handler repo request) +(define (edit-file-handler local-repo working-branch request) (catch 'file-error (lambda () (let* ((query (uri-query (request-uri request))) @@ -192,8 +191,12 @@ otherwise search for set/group data" (query-path (assoc-ref params 'file_path))) (if query-path - (build-json-response 200 - (fetch-file repo query-path)) + (begin + (git-invoke local-repo "fetch" "origin" working-branch) + (git-invoke local-repo "reset" "--hard" + (string-append "origin/" working-branch)) + (build-json-response 200 + (fetch-file local-repo query-path))) (throw 'file-error "Please provide a valid file path in the query")))) (lambda (key . args) @@ -327,7 +330,7 @@ otherwise search for set/group data" (('GET "species") (render-json (get-species-meta))) (('GET "edit") - (edit-file-handler +current-repo-path+ request)) + (edit-file-handler +current-repo-path+ +working-branch+ request)) (('POST "commit") (commit-file-handler +current-repo-path+ request body)) (('GET id) |
