summaryrefslogtreecommitdiff
path: root/server/src/git_root.rs
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-01-26 22:27:54 +0100
committerJoel Klinghed <the_jk@spawned.biz>2025-01-26 22:27:54 +0100
commit749c892b9cfc6b5b9937b4c3badc713101542fe1 (patch)
tree5cba0e9bc7a694e9939bcdb2281fba599df5db04 /server/src/git_root.rs
parent790e1af298aa7c9f39fb7cfe15615307ed87d597 (diff)
Use anyhow to reduce enum error types and map_err
Diffstat (limited to 'server/src/git_root.rs')
-rw-r--r--server/src/git_root.rs23
1 files changed, 3 insertions, 20 deletions
diff --git a/server/src/git_root.rs b/server/src/git_root.rs
index b1c533e..c6ee1fb 100644
--- a/server/src/git_root.rs
+++ b/server/src/git_root.rs
@@ -390,27 +390,12 @@ async fn setup_project_root(
Ok(repo)
}
-#[derive(Debug)]
-#[allow(dead_code)]
-enum GitOrSqlOrIoError {
- Git(git::Error),
- Sql(sqlx::Error),
- Io(std::io::Error),
-}
-
-async fn setup_projects_roots(
- roots: &Roots,
- config: &Config<'_>,
- db: &Db,
-) -> Result<(), GitOrSqlOrIoError> {
- fs_utils::create_dir_allow_existing(PathBuf::from(config.git_server_root.to_string()))
- .map_err(GitOrSqlOrIoError::Io)
- .await?;
+async fn setup_projects_roots(roots: &Roots, config: &Config<'_>, db: &Db) -> anyhow::Result<()> {
+ fs_utils::create_dir_allow_existing(PathBuf::from(config.git_server_root.to_string())).await?;
let projects = sqlx::query!("SELECT id,remote,main_branch FROM projects")
.fetch(&**db)
.map_ok(|r| (r.id, r.remote, r.main_branch))
- .map_err(GitOrSqlOrIoError::Sql)
.try_collect::<Vec<_>>()
.await
.unwrap();
@@ -418,9 +403,7 @@ async fn setup_projects_roots(
let mut project_repo: HashMap<String, Arc<git::Repository>> = HashMap::new();
for (id, remote, main_branch) in projects {
- let repo = setup_project_root(config, db, &id, remote, main_branch)
- .map_err(GitOrSqlOrIoError::Git)
- .await?;
+ let repo = setup_project_root(config, db, &id, remote, main_branch).await?;
project_repo.insert(id, repo);
}