about summary refs log tree commit diff stats
path: root/pkgs/by-name/ba/back/src/web/issue
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-26 10:00:45 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-26 10:01:56 +0100
commita3111a5d214db66b7d676940b8f8bfda5074bd45 (patch)
treea68cc1458386052a7c97a07b69bd161866ad7046 /pkgs/by-name/ba/back/src/web/issue
parentfix(hosts/server2): Use correct path to `vhack.eu/nixos-server` repo (diff)
downloadnixos-server-a3111a5d214db66b7d676940b8f8bfda5074bd45.zip
fix(pkgs/back): Use rocket to manage the configuration values
This reduces the amount of needed `unwraps`/`expects` and allows us to
streamline the parsing processes.
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ba/back/src/web/issue/mod.rs (renamed from pkgs/by-name/ba/back/src/issues/issue/mod.rs)15
-rw-r--r--pkgs/by-name/ba/back/src/web/issue/raw.rs (renamed from pkgs/by-name/ba/back/src/issues/issue/raw.rs)2
-rw-r--r--pkgs/by-name/ba/back/src/web/issue_show.rs (renamed from pkgs/by-name/ba/back/src/issues/issue_show.rs)0
3 files changed, 11 insertions, 6 deletions
diff --git a/pkgs/by-name/ba/back/src/issues/issue/mod.rs b/pkgs/by-name/ba/back/src/web/issue/mod.rs
index b78f473..79ef70f 100644
--- a/pkgs/by-name/ba/back/src/issues/issue/mod.rs
+++ b/pkgs/by-name/ba/back/src/web/issue/mod.rs
@@ -16,7 +16,7 @@ use gix::{bstr::ByteSlice, Commit, Id, ObjectId, Repository};
 use raw::{Operation, RawIssue};
 use rocket::response::content::RawHtml;
 
-use crate::SOURCE_CODE_REPOSITORY;
+use crate::config::BackConfig;
 
 use super::format::{BackString, Markdown};
 
@@ -114,12 +114,17 @@ impl<'a> Issue<'a> {
     pub fn from_commit_id(repo: &'a Repository, commit_id: ObjectId) -> Self {
         fn unwrap_id<'b>(repo: &Repository, id: &Commit<'b>) -> (RawIssue, Id<'b>) {
             let tree_obj = repo
-                .find_object(id.tree_id().unwrap())
+                .find_object(
+                    id.tree_id()
+                        .expect("All of git-bug's commits should have trees attached to them'"),
+                )
                 .expect("The object with this id should exist.")
                 .try_into_tree()
                 .expect("The git-bug's data model enforces this.");
 
-            let ops_ref = tree_obj.find_entry("ops").unwrap();
+            let ops_ref = tree_obj
+                .find_entry("ops")
+                .expect("All of git-bug's trees should contain a 'ops' json file");
 
             let issue_data = repo
                 .find_object(ops_ref.object_id())
@@ -237,7 +242,7 @@ impl<'a> Issue<'a> {
         ))
     }
 
-    pub fn to_html(&self) -> RawHtml<String> {
+    pub fn to_html(&self, config: &BackConfig) -> RawHtml<String> {
         let fmt_comments: String = self
             .comments
             .iter()
@@ -325,7 +330,7 @@ impl<'a> Issue<'a> {
    </body>
 </html>
 "#,
-                SOURCE_CODE_REPOSITORY.get().expect("This should be set")
+                config.source_code_repository_url
             ))
         }
     }
diff --git a/pkgs/by-name/ba/back/src/issues/issue/raw.rs b/pkgs/by-name/ba/back/src/web/issue/raw.rs
index 48d2a9f..bb447ec 100644
--- a/pkgs/by-name/ba/back/src/issues/issue/raw.rs
+++ b/pkgs/by-name/ba/back/src/web/issue/raw.rs
@@ -13,7 +13,7 @@ use gix::{bstr::ByteSlice, Repository};
 use serde::Deserialize;
 use serde_json::Value;
 
-use crate::issues::format::BackString;
+use crate::web::format::BackString;
 
 use super::{Author, Status};
 
diff --git a/pkgs/by-name/ba/back/src/issues/issue_show.rs b/pkgs/by-name/ba/back/src/web/issue_show.rs
index 638840e..638840e 100644
--- a/pkgs/by-name/ba/back/src/issues/issue_show.rs
+++ b/pkgs/by-name/ba/back/src/web/issue_show.rs