summary refs log tree commit diff stats
path: root/pkgs/by-name/ba/back/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ba/back/src/main.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkgs/by-name/ba/back/src/main.rs b/pkgs/by-name/ba/back/src/main.rs
index d0b0f81..86fe196 100644
--- a/pkgs/by-name/ba/back/src/main.rs
+++ b/pkgs/by-name/ba/back/src/main.rs
@@ -13,12 +13,14 @@ use std::{env::args, path::PathBuf, process, sync::OnceLock};
 
 use gix::ThreadSafeRepository;
 use rocket::{launch, routes};
+use url::Url;
 
 use crate::issues::{closed, open, show_issue, styles};
 
 mod issues;
 
 static REPOSITORY: OnceLock<ThreadSafeRepository> = OnceLock::new();
+static SOURCE_CODE_REPOSITORY: OnceLock<Url> = OnceLock::new();
 
 #[launch]
 fn rocket() -> _ {
@@ -31,6 +33,25 @@ fn rocket() -> _ {
             process::exit(1);
         }
     };
+    let source_code_url = {
+        match std::env::var("BACK_SOURCE_CODE_REPOSITORY_URL") {
+            Ok(value) => match Url::parse(&value) {
+                Ok(url) => url,
+                Err(err) => {
+                    eprintln!("Can't parse `BACK_SOURCE_CODE_REPOSITORY_URL` value as url: {err}");
+                    process::exit(1);
+                }
+            },
+            Err(err) => {
+                eprintln!("back needs you to specify a source code repositiory as `BACK_SOURCE_CODE_REPOSITORY_URL`: {err}");
+                process::exit(1);
+            }
+        }
+    };
+
+    SOURCE_CODE_REPOSITORY
+        .set(source_code_url)
+        .expect("This should be unset by this stage");
 
     REPOSITORY
         .set(