forked from kemitix/git-next
refactor: rename method as peel
Method on newtypes `unwrap` could be confused with the risky method of the same name for Option and Result.
This commit is contained in:
parent
d5d313064a
commit
a2940ec753
14 changed files with 19 additions and 19 deletions
|
@ -18,7 +18,7 @@ impl Handler<NotifyUser> for AlertsActor {
|
||||||
};
|
};
|
||||||
let net = self.net.clone();
|
let net = self.net.clone();
|
||||||
let shout = shout.clone();
|
let shout = shout.clone();
|
||||||
if let Some(user_notification) = self.history.sendable(msg.unwrap()) {
|
if let Some(user_notification) = self.history.sendable(msg.peel()) {
|
||||||
async move {
|
async move {
|
||||||
if let Some(webhook_config) = shout.webhook() {
|
if let Some(webhook_config) = shout.webhook() {
|
||||||
send_webhook(&user_notification, webhook_config, &net).await;
|
send_webhook(&user_notification, webhook_config, &net).await;
|
||||||
|
|
|
@ -7,6 +7,6 @@ impl Handler<UpdateShout> for AlertsActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
|
|
||||||
fn handle(&mut self, msg: UpdateShout, _ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: UpdateShout, _ctx: &mut Self::Context) -> Self::Result {
|
||||||
self.shout.replace(msg.unwrap());
|
self.shout.replace(msg.peel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl Handler<AdvanceMain> for RepoActor {
|
||||||
let repo_details = self.repo_details.clone();
|
let repo_details = self.repo_details.clone();
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
let message_token = self.message_token;
|
let message_token = self.message_token;
|
||||||
let commit = msg.unwrap();
|
let commit = msg.peel();
|
||||||
|
|
||||||
self.update_tui(RepoUpdate::AdvancingMain {
|
self.update_tui(RepoUpdate::AdvancingMain {
|
||||||
commit: commit.clone(),
|
commit: commit.clone(),
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl Handler<AdvanceNext> for RepoActor {
|
||||||
next,
|
next,
|
||||||
main,
|
main,
|
||||||
dev_commit_history,
|
dev_commit_history,
|
||||||
} = msg.unwrap();
|
} = msg.peel();
|
||||||
let repo_details = self.repo_details.clone();
|
let repo_details = self.repo_details.clone();
|
||||||
let repo_config = repo_config.clone();
|
let repo_config = repo_config.clone();
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl Handler<CheckCIStatus> for RepoActor {
|
||||||
|
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
let forge = self.forge.duplicate();
|
let forge = self.forge.duplicate();
|
||||||
let next = msg.unwrap();
|
let next = msg.peel();
|
||||||
let log = self.log.clone();
|
let log = self.log.clone();
|
||||||
|
|
||||||
self.update_tui(RepoUpdate::CheckingCI);
|
self.update_tui(RepoUpdate::CheckingCI);
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl Handler<ReceiveCIStatus> for RepoActor {
|
||||||
let log = self.log.clone();
|
let log = self.log.clone();
|
||||||
logger(log.as_ref(), "start: ReceiveCIStatus");
|
logger(log.as_ref(), "start: ReceiveCIStatus");
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
let (next, status) = msg.unwrap();
|
let (next, status) = msg.peel();
|
||||||
let forge_alias = self.repo_details.forge.forge_alias().clone();
|
let forge_alias = self.repo_details.forge.forge_alias().clone();
|
||||||
let repo_alias = self.repo_details.repo_alias.clone();
|
let repo_alias = self.repo_details.repo_alias.clone();
|
||||||
let message_token = self.message_token;
|
let message_token = self.message_token;
|
||||||
|
|
|
@ -15,7 +15,7 @@ impl Handler<ReceiveRepoConfig> for RepoActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
#[instrument(name = "RepoActor::ReceiveRepoConfig", skip_all, fields(repo = %self.repo_details, branches = ?msg))]
|
#[instrument(name = "RepoActor::ReceiveRepoConfig", skip_all, fields(repo = %self.repo_details, branches = ?msg))]
|
||||||
fn handle(&mut self, msg: ReceiveRepoConfig, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: ReceiveRepoConfig, ctx: &mut Self::Context) -> Self::Result {
|
||||||
let repo_config = msg.unwrap();
|
let repo_config = msg.peel();
|
||||||
self.update_tui(RepoUpdate::ReceiveRepoConfig {
|
self.update_tui(RepoUpdate::ReceiveRepoConfig {
|
||||||
repo_config: repo_config.clone(),
|
repo_config: repo_config.clone(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl Handler<ValidateRepo> for RepoActor {
|
||||||
logger(self.log.as_ref(), "start: ValidateRepo");
|
logger(self.log.as_ref(), "start: ValidateRepo");
|
||||||
|
|
||||||
// Message Token - make sure we are only triggered for the latest/current token
|
// Message Token - make sure we are only triggered for the latest/current token
|
||||||
match self.token_status(msg.unwrap()) {
|
match self.token_status(msg.peel()) {
|
||||||
TokenStatus::Current => {} // do nothing
|
TokenStatus::Current => {} // do nothing
|
||||||
TokenStatus::Expired => {
|
TokenStatus::Expired => {
|
||||||
logger(
|
logger(
|
||||||
|
|
|
@ -25,7 +25,7 @@ impl Handler<ReceiveAppConfig> for ServerActor {
|
||||||
|
|
||||||
self.do_send(
|
self.do_send(
|
||||||
ReceiveValidAppConfig::new(ValidAppConfig::new(
|
ReceiveValidAppConfig::new(ValidAppConfig::new(
|
||||||
msg.unwrap(),
|
msg.peel(),
|
||||||
socket_addr,
|
socket_addr,
|
||||||
server_storage,
|
server_storage,
|
||||||
)),
|
)),
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl Handler<ReceiveValidAppConfig> for ServerActor {
|
||||||
app_config,
|
app_config,
|
||||||
socket_address,
|
socket_address,
|
||||||
storage: server_storage,
|
storage: server_storage,
|
||||||
} = msg.unwrap();
|
} = msg.peel();
|
||||||
// shutdown any existing webhook actor
|
// shutdown any existing webhook actor
|
||||||
if let Some(webhook_actor_addr) = self.webhook_actor_addr.take() {
|
if let Some(webhook_actor_addr) = self.webhook_actor_addr.take() {
|
||||||
webhook_actor_addr.do_send(ShutdownWebhook);
|
webhook_actor_addr.do_send(ShutdownWebhook);
|
||||||
|
|
|
@ -5,6 +5,6 @@ impl actix::Handler<SubscribeToUpdates> for ServerActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
|
|
||||||
fn handle(&mut self, msg: SubscribeToUpdates, _ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: SubscribeToUpdates, _ctx: &mut Self::Context) -> Self::Result {
|
||||||
self.subscribers.push(msg.unwrap());
|
self.subscribers.push(msg.peel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,9 +240,9 @@ pub mod given {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn a_server_repo_config() -> ServerRepoConfig {
|
pub fn a_server_repo_config() -> ServerRepoConfig {
|
||||||
let main = a_branch_name().unwrap();
|
let main = a_branch_name().peel();
|
||||||
let next = a_branch_name().unwrap();
|
let next = a_branch_name().peel();
|
||||||
let dev = a_branch_name().unwrap();
|
let dev = a_branch_name().peel();
|
||||||
ServerRepoConfig::new(
|
ServerRepoConfig::new(
|
||||||
format!("{}/{}", a_name(), a_name()),
|
format!("{}/{}", a_name(), a_name()),
|
||||||
main.clone(),
|
main.clone(),
|
||||||
|
|
|
@ -39,13 +39,13 @@ macro_rules! newtype {
|
||||||
}
|
}
|
||||||
#[allow(clippy::missing_const_for_fn)]
|
#[allow(clippy::missing_const_for_fn)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn unwrap(self) -> $type {
|
pub fn peel(self) -> $type {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<$name> for $type {
|
impl From<$name> for $type {
|
||||||
fn from(value: $name) -> $type {
|
fn from(value: $name) -> $type {
|
||||||
value.unwrap()
|
value.peel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -716,9 +716,9 @@ mod forgejo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn a_server_repo_config() -> ServerRepoConfig {
|
pub fn a_server_repo_config() -> ServerRepoConfig {
|
||||||
let main = a_branch_name().unwrap();
|
let main = a_branch_name().peel();
|
||||||
let next = a_branch_name().unwrap();
|
let next = a_branch_name().peel();
|
||||||
let dev = a_branch_name().unwrap();
|
let dev = a_branch_name().peel();
|
||||||
ServerRepoConfig::new(
|
ServerRepoConfig::new(
|
||||||
format!("{}/{}", a_name(), a_name()),
|
format!("{}/{}", a_name(), a_name()),
|
||||||
main.clone(),
|
main.clone(),
|
||||||
|
|
Loading…
Reference in a new issue