mirror of
https://seed.radicle.dev/rad:zwTxygwuz5LDGBq255RA2CbNGrz8.git
synced 2026-11-28 22:30:28 +08:00
refactor: simplify how common fields Repository is created
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
+11
-9
@@ -137,13 +137,22 @@ impl<'a> RequestBuilder<'a> {
|
||||
let storage = &profile.storage;
|
||||
let repo = radicle_surf::Repository::open(paths::repository(storage, rid))?;
|
||||
let repo_project = repository.project()?;
|
||||
let repo_identity = repository.identity()?;
|
||||
let msg_repository = Repository {
|
||||
id: *rid,
|
||||
name: repo_project.name().to_string(),
|
||||
description: repo_project.description().to_string(),
|
||||
private: !repository.identity()?.visibility.is_public(),
|
||||
default_branch: repo_project.default_branch().to_string(),
|
||||
delegates: repository.delegates()?.iter().copied().collect(),
|
||||
};
|
||||
|
||||
let author = match extract_author(profile, event) {
|
||||
Ok(author) => author,
|
||||
Err(err) => {
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
|
||||
let push_info: Option<PushEvent>;
|
||||
let patch_info: Option<PatchEvent>;
|
||||
let event_type: EventType;
|
||||
@@ -242,14 +251,7 @@ impl<'a> RequestBuilder<'a> {
|
||||
let common = EventCommonFields {
|
||||
version: PROTOCOL_VERSION,
|
||||
event_type,
|
||||
repository: Repository {
|
||||
id: *rid,
|
||||
name: repo_project.name().to_string(),
|
||||
description: repo_project.description().to_string(),
|
||||
private: !repo_identity.visibility.is_public(),
|
||||
default_branch: repo_project.default_branch().to_string(),
|
||||
delegates: repository.delegates()?.iter().copied().collect(),
|
||||
},
|
||||
repository: msg_repository,
|
||||
};
|
||||
|
||||
Ok(Request::Trigger {
|
||||
|
||||
Reference in New Issue
Block a user