aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ba/back/src/web
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-09 00:11:10 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-09 13:44:46 +0100
commit90a1b14f4f310a2e518bc9bc19253d42b4cb6bed (patch)
treead29ce16fbeff06bab50a1012bdbbb59b2a791fc /pkgs/by-name/ba/back/src/web
parent{modules,tests}/back: Update to deal with newest back (diff)
downloadnixos-server-90a1b14f4f310a2e518bc9bc19253d42b4cb6bed.zip
pkgs/back: Do not store repositories in config
Otherwise, back will need to be restarted every time a new repository is added or removed.
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/ba/back/src/web/generate/mod.rs74
1 files changed, 36 insertions, 38 deletions
diff --git a/pkgs/by-name/ba/back/src/web/generate/mod.rs b/pkgs/by-name/ba/back/src/web/generate/mod.rs
index 10146bb..ae783a3 100644
--- a/pkgs/by-name/ba/back/src/web/generate/mod.rs
+++ b/pkgs/by-name/ba/back/src/web/generate/mod.rs
@@ -34,9 +34,9 @@ pub fn issues(
repo_path: &Path,
) -> error::Result<String> {
let repository = config
- .repositories
+ .repositories()?
.get(repo_path)?
- .open(config.repositories.scan_path())?;
+ .open(&config.scan_path)?;
let mut issue_list = issues_from_repository(&repository.to_thread_local())?
.into_iter()
@@ -76,9 +76,9 @@ struct IssueTemplate {
}
pub fn issue(config: &BackConfig, repo_path: &Path, prefix: Prefix) -> error::Result<String> {
let repository = config
- .repositories
+ .repositories()?
.get(repo_path)?
- .open(config.repositories.scan_path())?
+ .open(&config.scan_path)?
.to_thread_local();
let maybe_issue = issues_from_repository(&repository)?
@@ -113,39 +113,37 @@ struct RepoValue {
}
pub fn repos(config: &BackConfig) -> error::Result<String> {
let repos: Vec<RepoValue> = config
- .repositories
+ .repositories()?
.iter()
- .filter_map(
- |raw_repo| match raw_repo.open(config.repositories.scan_path()) {
- Ok(repo) => {
- let repo = repo.to_thread_local();
- let git_config = repo.config_snapshot();
+ .filter_map(|raw_repo| match raw_repo.open(&config.scan_path) {
+ Ok(repo) => {
+ let repo = repo.to_thread_local();
+ let git_config = repo.config_snapshot();
- let path = raw_repo.path().to_string_lossy().to_string();
+ let path = raw_repo.path().to_string_lossy().to_string();
- let owner = git_config
- .string("cgit.owner")
- .map(|v| v.to_string())
- .unwrap_or("<No owner>".to_owned());
+ let owner = git_config
+ .string("cgit.owner")
+ .map(|v| v.to_string())
+ .unwrap_or("<No owner>".to_owned());
- let description = fs::read_to_string(repo.git_dir().join("description"))
- .unwrap_or("<No description>".to_owned());
+ let description = fs::read_to_string(repo.git_dir().join("description"))
+ .unwrap_or("<No description>".to_owned());
- Some(RepoValue {
- description,
- owner,
- path,
- })
- }
- Err(err) => {
- info!(
- "Repo '{}' could not be opened: '{err}'",
- raw_repo.path().display()
- );
- None
- }
- },
- )
+ Some(RepoValue {
+ description,
+ owner,
+ path,
+ })
+ }
+ Err(err) => {
+ info!(
+ "Repo '{}' could not be opened: '{err}'",
+ raw_repo.path().display()
+ );
+ None
+ }
+ })
.collect();
Ok(ReposTemplate {
@@ -160,9 +158,9 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> {
use rss::{ChannelBuilder, Item, ItemBuilder};
let repository = config
- .repositories
+ .repositories()?
.get(repo_path)?
- .open(config.repositories.scan_path())?
+ .open(&config.scan_path)?
.to_thread_local();
let issues: Vec<CollapsedIssue> = issues_from_repository(&repository)?
@@ -182,7 +180,7 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> {
.link(format!(
"/{}/{}/issue/{}",
repo_path.display(),
- &config.root,
+ &config.root_url,
issue.id
))
.build()
@@ -207,7 +205,7 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> {
.link(format!(
"/{}/{}/issue/{}",
repo_path.display(),
- &config.root,
+ &config.root_url,
issue.id
))
.build()
@@ -219,8 +217,8 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> {
let channel = ChannelBuilder::default()
.title("Issues")
- .link(config.root.to_string())
- .description(format!("The rss feed for issues on {}.", &config.root))
+ .link(config.root_url.to_string())
+ .description(format!("The rss feed for issues on {}.", &config.root_url))
.items(items)
.build();
Ok(channel.to_string())