mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 19:30:38 +08:00
Remove unused create_repo handler
This handler wasn't being called by any code and diverges from a typical `rad init` flow, as it creates an empty repo with an initial empty commit. Removing this as it reduces maintenance burden
This commit is contained in:
@@ -1,13 +1,5 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::str::FromStr;
|
||||
|
||||
use radicle::git;
|
||||
use radicle::identity::project::ProjectName;
|
||||
use radicle::identity::{doc, Project, RepoId, Visibility};
|
||||
use radicle::rad::InitError;
|
||||
use radicle::storage::git::Repository;
|
||||
use radicle::storage::refs::branch_of;
|
||||
use radicle::storage::{SignRepository, WriteRepository};
|
||||
use radicle::identity::RepoId;
|
||||
use radicle_types as types;
|
||||
use radicle_types::error::Error;
|
||||
use radicle_types::traits::repo::{Repo, Show};
|
||||
@@ -129,73 +121,6 @@ pub fn repo_commit(
|
||||
ctx.repo_commit(rid, sha)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) async fn create_repo(
|
||||
ctx: tauri::State<'_, AppState>,
|
||||
name: String,
|
||||
description: String,
|
||||
) -> Result<(), Error> {
|
||||
let profile = &ctx.profile;
|
||||
let storage = &profile.storage;
|
||||
let signer = ctx.profile.signer()?;
|
||||
let config = git2::Config::open_default()?;
|
||||
// SAFETY: "master" is always a valid RefString
|
||||
let default_branch = git::fmt::RefString::try_from(
|
||||
config
|
||||
.get_string("init.defaultBranch")
|
||||
.unwrap_or("master".to_owned()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let name = ProjectName::from_str(&name)?;
|
||||
if description.len() > doc::MAX_STRING_LENGTH {
|
||||
return Err(Error::ProjectError(
|
||||
radicle::identity::project::ProjectError::Description("Cannot exceed 255 characters."),
|
||||
));
|
||||
}
|
||||
|
||||
let visibility = Visibility::Private {
|
||||
allow: BTreeSet::default(),
|
||||
};
|
||||
|
||||
let proj = Project::new(name, description, default_branch.clone()).map_err(|errs| {
|
||||
InitError::ProjectPayload(
|
||||
errs.into_iter()
|
||||
.map(|err| err.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", "),
|
||||
)
|
||||
})?;
|
||||
let doc = radicle::identity::Doc::initial(proj, profile.public_key.into(), visibility);
|
||||
let (project, identity) = Repository::init(&doc, &storage, &signer)?;
|
||||
|
||||
let tree_id = {
|
||||
let mut index = project.backend.index()?;
|
||||
|
||||
index.write_tree()
|
||||
}?;
|
||||
let sig = project.backend.signature()?;
|
||||
let tree = project.backend.find_tree(tree_id)?;
|
||||
|
||||
project.set_remote_identity_root_to(signer.public_key(), identity)?;
|
||||
project.set_identity_head_to(identity)?;
|
||||
|
||||
let base = project
|
||||
.backend
|
||||
.commit(Some("HEAD"), &sig, &sig, "Initial commit", &tree, &[])?;
|
||||
|
||||
let ns_head = branch_of(&ctx.profile.public_key, &default_branch);
|
||||
project
|
||||
.backend
|
||||
.reference(ns_head.as_str(), base, false, "Created namespace ref")?;
|
||||
|
||||
project.set_canonical_symbolic_refs("set-canonical from create_repo")?;
|
||||
project.set_default_branch_to_canonical_head()?;
|
||||
project.sign_refs(&signer)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn seed(ctx: tauri::State<AppState>, rid: RepoId) -> Result<(), Error> {
|
||||
ctx.seed(rid)
|
||||
|
||||
@@ -54,7 +54,6 @@ pub fn run() {
|
||||
inbox::list_notifications,
|
||||
profile::alias,
|
||||
profile::config,
|
||||
repo::create_repo,
|
||||
repo::diff_stats,
|
||||
repo::list_commits,
|
||||
repo::list_repo_commits,
|
||||
|
||||
Reference in New Issue
Block a user