mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-25 10:33:21 +03:00
chore: remove legacy error in favor of new error system
This commit is contained in:
parent
d0db6a67df
commit
2aaacdfca7
@ -132,21 +132,21 @@ pub fn into_anyhow(err: impl ErrorWithContext + Send + Sync + 'static) -> anyhow
|
|||||||
/// Whenever `thiserror` is involved, this error type should be used if the alternative would be to write
|
/// Whenever `thiserror` is involved, this error type should be used if the alternative would be to write
|
||||||
/// a `thiserror` which just forwards its context (like `app::Error` previously).
|
/// a `thiserror` which just forwards its context (like `app::Error` previously).
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Error2(anyhow::Error);
|
pub struct Error(anyhow::Error);
|
||||||
|
|
||||||
impl From<anyhow::Error> for Error2 {
|
impl From<anyhow::Error> for Error {
|
||||||
fn from(value: anyhow::Error) -> Self {
|
fn from(value: anyhow::Error) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Error2> for anyhow::Error {
|
impl From<Error> for anyhow::Error {
|
||||||
fn from(value: Error2) -> Self {
|
fn from(value: Error) -> Self {
|
||||||
value.0
|
value.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E> From<E> for Error2
|
impl<E> From<E> for Error
|
||||||
where
|
where
|
||||||
E: ErrorWithContext + Send + Sync + 'static,
|
E: ErrorWithContext + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
@ -155,7 +155,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error2 {
|
impl Error {
|
||||||
/// A manual, none-overlapping implementation of `From` (or else there are conflicts).
|
/// A manual, none-overlapping implementation of `From` (or else there are conflicts).
|
||||||
pub fn from_err(err: impl std::error::Error + Send + Sync + 'static) -> Self {
|
pub fn from_err(err: impl std::error::Error + Send + Sync + 'static) -> Self {
|
||||||
Self(err.into())
|
Self(err.into())
|
||||||
@ -186,53 +186,3 @@ impl Error2 {
|
|||||||
self.0.downcast_ref::<E>()
|
self.0.downcast_ref::<E>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) use legacy::Error;
|
|
||||||
mod legacy {
|
|
||||||
use serde::{ser::SerializeMap, Serialize};
|
|
||||||
|
|
||||||
use crate::error::Code;
|
|
||||||
use crate::projects;
|
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum Error {
|
|
||||||
#[error("[{code}]: {message}")]
|
|
||||||
UserError { code: Code, message: String },
|
|
||||||
#[error("[errors.unknown]: Something went wrong")]
|
|
||||||
Unknown,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Error {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
let (code, message) = match self {
|
|
||||||
Error::UserError { code, message } => (code.to_string(), message.to_string()),
|
|
||||||
Error::Unknown => (
|
|
||||||
Code::Unknown.to_string(),
|
|
||||||
"Something went wrong".to_string(),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut map = serializer.serialize_map(Some(2))?;
|
|
||||||
map.serialize_entry("code", &code)?;
|
|
||||||
map.serialize_entry("message", &message)?;
|
|
||||||
map.end()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<anyhow::Error> for Error {
|
|
||||||
fn from(error: anyhow::Error) -> Self {
|
|
||||||
tracing::error!(?error);
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<projects::controller::GetError> for Error {
|
|
||||||
fn from(error: projects::controller::GetError) -> Self {
|
|
||||||
tracing::error!(?error);
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -87,26 +87,6 @@ pub enum HelpError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<HelpError> for crate::error::Error {
|
|
||||||
fn from(value: HelpError) -> Self {
|
|
||||||
match value {
|
|
||||||
HelpError::NoUrlSet => Self::UserError {
|
|
||||||
code: crate::error::Code::ProjectGitRemote,
|
|
||||||
message: "no url set for remote".to_string(),
|
|
||||||
},
|
|
||||||
HelpError::UrlConvertError(error) => Self::UserError {
|
|
||||||
code: crate::error::Code::ProjectGitRemote,
|
|
||||||
message: error.to_string(),
|
|
||||||
},
|
|
||||||
HelpError::Git(error) => {
|
|
||||||
tracing::error!(?error, "failed to create auth credentials");
|
|
||||||
Self::Unknown
|
|
||||||
}
|
|
||||||
HelpError::Other(error) => error.into(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for HelpError {
|
impl ErrorWithContext for HelpError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
|
@ -32,21 +32,6 @@ pub enum OpenError {
|
|||||||
Other(anyhow::Error),
|
Other(anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<OpenError> for crate::error::Error {
|
|
||||||
fn from(value: OpenError) -> Self {
|
|
||||||
match value {
|
|
||||||
OpenError::NotFound(path) => crate::error::Error::UserError {
|
|
||||||
code: crate::error::Code::Projects,
|
|
||||||
message: format!("{} not found", path.display()),
|
|
||||||
},
|
|
||||||
OpenError::Other(error) => {
|
|
||||||
tracing::error!(?error);
|
|
||||||
crate::error::Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for OpenError {
|
impl ErrorWithContext for OpenError {
|
||||||
fn context(&self) -> Option<crate::error::Context> {
|
fn context(&self) -> Option<crate::error::Context> {
|
||||||
match self {
|
match self {
|
||||||
@ -640,26 +625,6 @@ pub enum RemoteError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RemoteError> for crate::error::Error {
|
|
||||||
fn from(value: RemoteError) -> Self {
|
|
||||||
match value {
|
|
||||||
RemoteError::Help(error) => error.into(),
|
|
||||||
RemoteError::Network => crate::error::Error::UserError {
|
|
||||||
code: crate::error::Code::ProjectGitRemote,
|
|
||||||
message: "Network erorr occured".to_string(),
|
|
||||||
},
|
|
||||||
RemoteError::Auth => crate::error::Error::UserError {
|
|
||||||
code: crate::error::Code::ProjectGitAuth,
|
|
||||||
message: "Project remote authentication error".to_string(),
|
|
||||||
},
|
|
||||||
RemoteError::Other(error) => {
|
|
||||||
tracing::error!(?error);
|
|
||||||
crate::error::Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for RemoteError {
|
impl ErrorWithContext for RemoteError {
|
||||||
fn context(&self) -> Option<error::Context> {
|
fn context(&self) -> Option<error::Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
|
@ -7,7 +7,7 @@ use anyhow::{Context, Result};
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
use super::{storage, storage::UpdateRequest, Project, ProjectId};
|
use super::{storage, storage::UpdateRequest, Project, ProjectId};
|
||||||
use crate::error::{AnyhowContextExt, Code, Error2, ErrorWithContext};
|
use crate::error::{AnyhowContextExt, Code, Error, ErrorWithContext};
|
||||||
use crate::{error, gb_repository, project_repository, users};
|
use crate::{error, gb_repository, project_repository, users};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@ -199,11 +199,11 @@ impl Controller {
|
|||||||
self.projects_storage.list().map_err(Into::into)
|
self.projects_storage.list().map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn delete(&self, id: &ProjectId) -> Result<(), Error2> {
|
pub async fn delete(&self, id: &ProjectId) -> Result<(), Error> {
|
||||||
let project = match self.projects_storage.get(id) {
|
let project = match self.projects_storage.get(id) {
|
||||||
Ok(project) => Ok(project),
|
Ok(project) => Ok(project),
|
||||||
Err(super::storage::Error::NotFound) => return Ok(()),
|
Err(super::storage::Error::NotFound) => return Ok(()),
|
||||||
Err(error) => Err(Error2::from_err(error)),
|
Err(error) => Err(Error::from_err(error)),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
if let Some(watchers) = &self.watchers {
|
if let Some(watchers) = &self.watchers {
|
||||||
|
@ -3,7 +3,7 @@ use std::path;
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
|
||||||
use super::{Database, Session};
|
use super::{Database, Session};
|
||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
use crate::{
|
use crate::{
|
||||||
gb_repository, project_repository,
|
gb_repository, project_repository,
|
||||||
projects::{self, ProjectId},
|
projects::{self, ProjectId},
|
||||||
@ -38,7 +38,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
earliest_timestamp_ms: Option<u128>,
|
earliest_timestamp_ms: Option<u128>,
|
||||||
) -> Result<Vec<Session>, Error2> {
|
) -> Result<Vec<Session>, Error> {
|
||||||
let sessions = self
|
let sessions = self
|
||||||
.sessions_database
|
.sessions_database
|
||||||
.list_by_project_id(project_id, earliest_timestamp_ms)?;
|
.list_by_project_id(project_id, earliest_timestamp_ms)?;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
use std::{collections::HashMap, path, sync::Arc};
|
use std::{collections::HashMap, path, sync::Arc};
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
@ -71,7 +71,7 @@ impl Controller {
|
|||||||
message: &str,
|
message: &str,
|
||||||
ownership: Option<&BranchOwnershipClaims>,
|
ownership: Option<&BranchOwnershipClaims>,
|
||||||
run_hooks: bool,
|
run_hooks: bool,
|
||||||
) -> Result<git::Oid, Error2> {
|
) -> Result<git::Oid, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.create_commit(project_id, branch_id, message, ownership, run_hooks)
|
.create_commit(project_id, branch_id, message, ownership, run_hooks)
|
||||||
@ -82,7 +82,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_name: &git::RemoteRefname,
|
branch_name: &git::RemoteRefname,
|
||||||
) -> Result<bool, Error2> {
|
) -> Result<bool, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.can_apply_remote_branch(project_id, branch_name)
|
.can_apply_remote_branch(project_id, branch_name)
|
||||||
@ -92,7 +92,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<bool, Error2> {
|
) -> Result<bool, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.can_apply_virtual_branch(project_id, branch_id)
|
.can_apply_virtual_branch(project_id, branch_id)
|
||||||
@ -103,7 +103,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_ids: Vec<BranchId>,
|
branch_ids: Vec<BranchId>,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let vbranches_state = self
|
let vbranches_state = self
|
||||||
.inner(project_id)
|
.inner(project_id)
|
||||||
.await
|
.await
|
||||||
@ -126,7 +126,7 @@ impl Controller {
|
|||||||
pub async fn list_virtual_branches(
|
pub async fn list_virtual_branches(
|
||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
) -> Result<(Vec<super::VirtualBranch>, bool, Vec<git::diff::FileDiff>), Error2> {
|
) -> Result<(Vec<super::VirtualBranch>, bool, Vec<git::diff::FileDiff>), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.list_virtual_branches(project_id)
|
.list_virtual_branches(project_id)
|
||||||
@ -137,7 +137,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
create: &super::branch::BranchCreateRequest,
|
create: &super::branch::BranchCreateRequest,
|
||||||
) -> Result<BranchId, Error2> {
|
) -> Result<BranchId, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.create_virtual_branch(project_id, create)
|
.create_virtual_branch(project_id, create)
|
||||||
@ -148,7 +148,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch: &git::Refname,
|
branch: &git::Refname,
|
||||||
) -> Result<BranchId, Error2> {
|
) -> Result<BranchId, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.create_virtual_branch_from_branch(project_id, branch)
|
.create_virtual_branch_from_branch(project_id, branch)
|
||||||
@ -158,7 +158,7 @@ impl Controller {
|
|||||||
pub async fn get_base_branch_data(
|
pub async fn get_base_branch_data(
|
||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
) -> Result<Option<BaseBranch>, Error2> {
|
) -> Result<Option<BaseBranch>, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.get_base_branch_data(project_id)
|
.get_base_branch_data(project_id)
|
||||||
@ -168,7 +168,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<Vec<RemoteBranchFile>, Error2> {
|
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.list_remote_commit_files(project_id, commit_oid)
|
.list_remote_commit_files(project_id, commit_oid)
|
||||||
@ -178,7 +178,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
target_branch: &git::RemoteRefname,
|
target_branch: &git::RemoteRefname,
|
||||||
) -> Result<super::BaseBranch, Error2> {
|
) -> Result<super::BaseBranch, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.set_base_branch(project_id, target_branch)
|
.set_base_branch(project_id, target_branch)
|
||||||
@ -188,14 +188,14 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.merge_virtual_branch_upstream(project_id, branch_id)
|
.merge_virtual_branch_upstream(project_id, branch_id)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_base_branch(&self, project_id: &ProjectId) -> Result<(), Error2> {
|
pub async fn update_base_branch(&self, project_id: &ProjectId) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.update_base_branch(project_id)
|
.update_base_branch(project_id)
|
||||||
@ -206,7 +206,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_update: super::branch::BranchUpdateRequest,
|
branch_update: super::branch::BranchUpdateRequest,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.update_virtual_branch(project_id, branch_update)
|
.update_virtual_branch(project_id, branch_update)
|
||||||
@ -216,7 +216,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.delete_virtual_branch(project_id, branch_id)
|
.delete_virtual_branch(project_id, branch_id)
|
||||||
@ -227,7 +227,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.apply_virtual_branch(project_id, branch_id)
|
.apply_virtual_branch(project_id, branch_id)
|
||||||
@ -238,7 +238,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
ownership: &BranchOwnershipClaims,
|
ownership: &BranchOwnershipClaims,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.unapply_ownership(project_id, ownership)
|
.unapply_ownership(project_id, ownership)
|
||||||
@ -249,7 +249,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
files: &Vec<String>,
|
files: &Vec<String>,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.reset_files(project_id, files)
|
.reset_files(project_id, files)
|
||||||
@ -261,7 +261,7 @@ impl Controller {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
ownership: &BranchOwnershipClaims,
|
ownership: &BranchOwnershipClaims,
|
||||||
) -> Result<git::Oid, Error2> {
|
) -> Result<git::Oid, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.amend(project_id, branch_id, ownership)
|
.amend(project_id, branch_id, ownership)
|
||||||
@ -273,7 +273,7 @@ impl Controller {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
target_commit_oid: git::Oid,
|
target_commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.reset_virtual_branch(project_id, branch_id, target_commit_oid)
|
.reset_virtual_branch(project_id, branch_id, target_commit_oid)
|
||||||
@ -284,7 +284,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.unapply_virtual_branch(project_id, branch_id)
|
.unapply_virtual_branch(project_id, branch_id)
|
||||||
@ -297,7 +297,7 @@ impl Controller {
|
|||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
askpass: Option<(AskpassBroker, Option<BranchId>)>,
|
askpass: Option<(AskpassBroker, Option<BranchId>)>,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.push_virtual_branch(project_id, branch_id, with_force, askpass)
|
.push_virtual_branch(project_id, branch_id, with_force, askpass)
|
||||||
@ -309,7 +309,7 @@ impl Controller {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<Option<git::Oid>, Error2> {
|
) -> Result<Option<git::Oid>, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.cherry_pick(project_id, branch_id, commit_oid)
|
.cherry_pick(project_id, branch_id, commit_oid)
|
||||||
@ -319,7 +319,7 @@ impl Controller {
|
|||||||
pub async fn list_remote_branches(
|
pub async fn list_remote_branches(
|
||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
) -> Result<Vec<super::RemoteBranch>, Error2> {
|
) -> Result<Vec<super::RemoteBranch>, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.list_remote_branches(project_id)
|
.list_remote_branches(project_id)
|
||||||
@ -329,7 +329,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
refname: &git::Refname,
|
refname: &git::Refname,
|
||||||
) -> Result<super::RemoteBranchData, Error2> {
|
) -> Result<super::RemoteBranchData, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.get_remote_branch_data(project_id, refname)
|
.get_remote_branch_data(project_id, refname)
|
||||||
@ -340,7 +340,7 @@ impl Controller {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.squash(project_id, branch_id, commit_oid)
|
.squash(project_id, branch_id, commit_oid)
|
||||||
@ -353,7 +353,7 @@ impl Controller {
|
|||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
message: &str,
|
message: &str,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.update_commit_message(project_id, branch_id, commit_oid, message)
|
.update_commit_message(project_id, branch_id, commit_oid, message)
|
||||||
@ -364,7 +364,7 @@ impl Controller {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
askpass: Option<(AskpassBroker, String)>,
|
askpass: Option<(AskpassBroker, String)>,
|
||||||
) -> Result<BaseBranch, Error2> {
|
) -> Result<BaseBranch, Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.fetch_from_target(project_id, askpass)
|
.fetch_from_target(project_id, askpass)
|
||||||
@ -376,7 +376,7 @@ impl Controller {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
target_branch_id: &BranchId,
|
target_branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
self.inner(project_id)
|
self.inner(project_id)
|
||||||
.await
|
.await
|
||||||
.move_commit(project_id, target_branch_id, commit_oid)
|
.move_commit(project_id, target_branch_id, commit_oid)
|
||||||
@ -420,7 +420,7 @@ impl ControllerInner {
|
|||||||
message: &str,
|
message: &str,
|
||||||
ownership: Option<&BranchOwnershipClaims>,
|
ownership: Option<&BranchOwnershipClaims>,
|
||||||
run_hooks: bool,
|
run_hooks: bool,
|
||||||
) -> Result<git::Oid, Error2> {
|
) -> Result<git::Oid, Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
||||||
@ -453,7 +453,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_name: &git::RemoteRefname,
|
branch_name: &git::RemoteRefname,
|
||||||
) -> Result<bool, Error2> {
|
) -> Result<bool, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user()?;
|
let user = self.users.get_user()?;
|
||||||
@ -474,7 +474,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<bool, Error2> {
|
) -> Result<bool, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user().context("failed to get user")?;
|
let user = self.users.get_user().context("failed to get user")?;
|
||||||
@ -493,7 +493,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_ids: Vec<BranchId>,
|
branch_ids: Vec<BranchId>,
|
||||||
) -> Result<VirtualBranches, Error2> {
|
) -> Result<VirtualBranches, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user().context("failed to get user")?;
|
let user = self.users.get_user().context("failed to get user")?;
|
||||||
@ -547,7 +547,7 @@ impl ControllerInner {
|
|||||||
pub async fn list_virtual_branches(
|
pub async fn list_virtual_branches(
|
||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
) -> Result<(Vec<super::VirtualBranch>, bool, Vec<git::diff::FileDiff>), Error2> {
|
) -> Result<(Vec<super::VirtualBranch>, bool, Vec<git::diff::FileDiff>), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -559,7 +559,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
create: &super::branch::BranchCreateRequest,
|
create: &super::branch::BranchCreateRequest,
|
||||||
) -> Result<BranchId, Error2> {
|
) -> Result<BranchId, Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -573,7 +573,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch: &git::Refname,
|
branch: &git::Refname,
|
||||||
) -> Result<BranchId, Error2> {
|
) -> Result<BranchId, Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
||||||
@ -601,7 +601,7 @@ impl ControllerInner {
|
|||||||
pub fn get_base_branch_data(
|
pub fn get_base_branch_data(
|
||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
) -> Result<Option<BaseBranch>, Error2> {
|
) -> Result<Option<BaseBranch>, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user()?;
|
let user = self.users.get_user()?;
|
||||||
@ -621,7 +621,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<Vec<RemoteBranchFile>, Error2> {
|
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let use_context = project_repository
|
let use_context = project_repository
|
||||||
@ -641,7 +641,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
target_branch: &git::RemoteRefname,
|
target_branch: &git::RemoteRefname,
|
||||||
) -> Result<super::BaseBranch, Error2> {
|
) -> Result<super::BaseBranch, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let user = self.users.get_user()?;
|
let user = self.users.get_user()?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
@ -663,7 +663,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
||||||
@ -689,7 +689,7 @@ impl ControllerInner {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_base_branch(&self, project_id: &ProjectId) -> Result<(), Error2> {
|
pub async fn update_base_branch(&self, project_id: &ProjectId) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
||||||
@ -718,7 +718,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_update: super::branch::BranchUpdateRequest,
|
branch_update: super::branch::BranchUpdateRequest,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -731,7 +731,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -744,7 +744,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
||||||
@ -774,7 +774,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
ownership: &BranchOwnershipClaims,
|
ownership: &BranchOwnershipClaims,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -787,7 +787,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
ownership: &Vec<String>,
|
ownership: &Vec<String>,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |_, project_repository, _| {
|
self.with_verify_branch(project_id, |_, project_repository, _| {
|
||||||
@ -800,7 +800,7 @@ impl ControllerInner {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
ownership: &BranchOwnershipClaims,
|
ownership: &BranchOwnershipClaims,
|
||||||
) -> Result<git::Oid, Error2> {
|
) -> Result<git::Oid, Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -814,7 +814,7 @@ impl ControllerInner {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
target_commit_oid: git::Oid,
|
target_commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -832,7 +832,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -848,7 +848,7 @@ impl ControllerInner {
|
|||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
askpass: Option<(AskpassBroker, Option<BranchId>)>,
|
askpass: Option<(AskpassBroker, Option<BranchId>)>,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
let helper = self.helper.clone();
|
let helper = self.helper.clone();
|
||||||
let project_id = *project_id;
|
let project_id = *project_id;
|
||||||
@ -864,7 +864,7 @@ impl ControllerInner {
|
|||||||
)?)
|
)?)
|
||||||
})?
|
})?
|
||||||
.await
|
.await
|
||||||
.map_err(Error2::from_err)?
|
.map_err(Error::from_err)?
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn cherry_pick(
|
pub async fn cherry_pick(
|
||||||
@ -872,7 +872,7 @@ impl ControllerInner {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<Option<git::Oid>, Error2> {
|
) -> Result<Option<git::Oid>, Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -884,7 +884,7 @@ impl ControllerInner {
|
|||||||
pub fn list_remote_branches(
|
pub fn list_remote_branches(
|
||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
) -> Result<Vec<super::RemoteBranch>, Error2> {
|
) -> Result<Vec<super::RemoteBranch>, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user()?;
|
let user = self.users.get_user()?;
|
||||||
@ -904,7 +904,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
refname: &git::Refname,
|
refname: &git::Refname,
|
||||||
) -> Result<super::RemoteBranchData, Error2> {
|
) -> Result<super::RemoteBranchData, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user()?;
|
let user = self.users.get_user()?;
|
||||||
@ -926,7 +926,7 @@ impl ControllerInner {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
@ -941,7 +941,7 @@ impl ControllerInner {
|
|||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
message: &str,
|
message: &str,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, _| {
|
||||||
super::update_commit_message(
|
super::update_commit_message(
|
||||||
@ -959,7 +959,7 @@ impl ControllerInner {
|
|||||||
&self,
|
&self,
|
||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
askpass: Option<(AskpassBroker, String)>,
|
askpass: Option<(AskpassBroker, String)>,
|
||||||
) -> Result<BaseBranch, Error2> {
|
) -> Result<BaseBranch, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let mut project_repository = project_repository::Repository::open(&project)?;
|
let mut project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user()?;
|
let user = self.users.get_user()?;
|
||||||
@ -1015,7 +1015,7 @@ impl ControllerInner {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
target_branch_id: &BranchId,
|
target_branch_id: &BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let _permit = self.semaphore.acquire().await;
|
let _permit = self.semaphore.acquire().await;
|
||||||
|
|
||||||
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
self.with_verify_branch(project_id, |gb_repository, project_repository, user| {
|
||||||
@ -1050,8 +1050,8 @@ impl ControllerInner {
|
|||||||
&gb_repository::Repository,
|
&gb_repository::Repository,
|
||||||
&project_repository::Repository,
|
&project_repository::Repository,
|
||||||
Option<&users::User>,
|
Option<&users::User>,
|
||||||
) -> Result<T, Error2>,
|
) -> Result<T, Error>,
|
||||||
) -> Result<T, Error2> {
|
) -> Result<T, Error> {
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
let user = self.users.get_user()?;
|
let user = self.users.get_user()?;
|
||||||
@ -1072,10 +1072,10 @@ impl ControllerInner {
|
|||||||
&gb_repository::Repository,
|
&gb_repository::Repository,
|
||||||
&project_repository::Repository,
|
&project_repository::Repository,
|
||||||
Option<&users::User>,
|
Option<&users::User>,
|
||||||
) -> Result<T, Error2>
|
) -> Result<T, Error>
|
||||||
+ Send
|
+ Send
|
||||||
+ 'static,
|
+ 'static,
|
||||||
) -> Result<JoinHandle<Result<T, Error2>>, Error2> {
|
) -> Result<JoinHandle<Result<T, Error>>, Error> {
|
||||||
let local_data_dir = self.local_data_dir.clone();
|
let local_data_dir = self.local_data_dir.clone();
|
||||||
let project = self.projects.get(project_id)?;
|
let project = self.projects.get(project_id)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)?;
|
let project_repository = project_repository::Repository::open(&project)?;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
use super::{branch::BranchOwnershipClaims, BranchId, GITBUTLER_INTEGRATION_REFERENCE};
|
use super::{branch::BranchOwnershipClaims, BranchId, GITBUTLER_INTEGRATION_REFERENCE};
|
||||||
use crate::error::{AnyhowContextExt, Code, Context, ErrorWithContext};
|
use crate::error::{AnyhowContextExt, Code, Context, ErrorWithContext};
|
||||||
use crate::{
|
use crate::{
|
||||||
error,
|
error, git,
|
||||||
error::Error,
|
|
||||||
git,
|
|
||||||
project_repository::{self, RemoteError},
|
project_repository::{self, RemoteError},
|
||||||
projects::ProjectId,
|
projects::ProjectId,
|
||||||
};
|
};
|
||||||
@ -20,36 +18,6 @@ pub enum VerifyError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<VerifyError> for crate::error::Error {
|
|
||||||
fn from(value: VerifyError) -> Self {
|
|
||||||
match value {
|
|
||||||
VerifyError::DetachedHead => crate::error::Error::UserError {
|
|
||||||
code: crate::error::Code::ProjectHead,
|
|
||||||
message: format!(
|
|
||||||
"Project in detached head state. Please checkout {0} to continue.",
|
|
||||||
GITBUTLER_INTEGRATION_REFERENCE.branch()
|
|
||||||
),
|
|
||||||
},
|
|
||||||
VerifyError::InvalidHead(head) => crate::error::Error::UserError {
|
|
||||||
code: crate::error::Code::ProjectHead,
|
|
||||||
message: format!(
|
|
||||||
"Project is on {}. Please checkout {} to continue.",
|
|
||||||
head,
|
|
||||||
GITBUTLER_INTEGRATION_REFERENCE.branch()
|
|
||||||
),
|
|
||||||
},
|
|
||||||
VerifyError::NoIntegrationCommit => crate::error::Error::UserError {
|
|
||||||
code: crate::error::Code::ProjectHead,
|
|
||||||
message: "GibButler's integration commit not found on head.".to_string(),
|
|
||||||
},
|
|
||||||
VerifyError::Other(error) => {
|
|
||||||
tracing::error!(?error);
|
|
||||||
crate::error::Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for VerifyError {
|
impl ErrorWithContext for VerifyError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -77,35 +45,6 @@ impl ErrorWithContext for VerifyError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum DeleteBranchError {
|
|
||||||
#[error(transparent)]
|
|
||||||
UnapplyBranch(#[from] UnapplyBranchError),
|
|
||||||
#[error(transparent)]
|
|
||||||
Other(#[from] anyhow::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DeleteBranchError> for Error {
|
|
||||||
fn from(value: DeleteBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
DeleteBranchError::UnapplyBranch(error) => error.into(),
|
|
||||||
DeleteBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "delete branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for DeleteBranchError {
|
|
||||||
fn context(&self) -> Option<Context> {
|
|
||||||
match self {
|
|
||||||
DeleteBranchError::UnapplyBranch(error) => error.context(),
|
|
||||||
DeleteBranchError::Other(error) => error.custom_context(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum ResetBranchError {
|
pub enum ResetBranchError {
|
||||||
#[error("commit {0} not in the branch")]
|
#[error("commit {0} not in the branch")]
|
||||||
@ -118,23 +57,6 @@ pub enum ResetBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ResetBranchError> for Error {
|
|
||||||
fn from(value: ResetBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
ResetBranchError::BranchNotFound(error) => error.into(),
|
|
||||||
ResetBranchError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
ResetBranchError::CommitNotFoundInBranch(oid) => Error::UserError {
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
message: format!("commit {} not found", oid),
|
|
||||||
},
|
|
||||||
ResetBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "reset branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for ResetBranchError {
|
impl ErrorWithContext for ResetBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -162,24 +84,6 @@ pub enum ApplyBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ApplyBranchError> for Error {
|
|
||||||
fn from(value: ApplyBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
ApplyBranchError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
ApplyBranchError::Conflict(error) => error.into(),
|
|
||||||
ApplyBranchError::BranchNotFound(error) => error.into(),
|
|
||||||
ApplyBranchError::BranchConflicts(id) => Error::UserError {
|
|
||||||
message: format!("Branch {} is in a conflicing state", id),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
ApplyBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "apply branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for ApplyBranchError {
|
impl ErrorWithContext for ApplyBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -205,19 +109,6 @@ pub enum UnapplyOwnershipError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<UnapplyOwnershipError> for Error {
|
|
||||||
fn from(value: UnapplyOwnershipError) -> Self {
|
|
||||||
match value {
|
|
||||||
UnapplyOwnershipError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
UnapplyOwnershipError::Conflict(error) => error.into(),
|
|
||||||
UnapplyOwnershipError::Other(error) => {
|
|
||||||
tracing::error!(?error, "unapply ownership error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for UnapplyOwnershipError {
|
impl ErrorWithContext for UnapplyOwnershipError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -238,19 +129,6 @@ pub enum UnapplyBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<UnapplyBranchError> for Error {
|
|
||||||
fn from(value: UnapplyBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
UnapplyBranchError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
UnapplyBranchError::BranchNotFound(error) => error.into(),
|
|
||||||
UnapplyBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "unapply branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for UnapplyBranchError {
|
impl ErrorWithContext for UnapplyBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -269,18 +147,6 @@ pub enum ListVirtualBranchesError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ListVirtualBranchesError> for Error {
|
|
||||||
fn from(value: ListVirtualBranchesError) -> Self {
|
|
||||||
match value {
|
|
||||||
ListVirtualBranchesError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
ListVirtualBranchesError::Other(error) => {
|
|
||||||
tracing::error!(?error, "list virtual branches error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for ListVirtualBranchesError {
|
impl ErrorWithContext for ListVirtualBranchesError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
match self {
|
match self {
|
||||||
@ -298,18 +164,6 @@ pub enum CreateVirtualBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CreateVirtualBranchError> for Error {
|
|
||||||
fn from(value: CreateVirtualBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
CreateVirtualBranchError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
CreateVirtualBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "create virtual branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for CreateVirtualBranchError {
|
impl ErrorWithContext for CreateVirtualBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
match self {
|
match self {
|
||||||
@ -329,19 +183,6 @@ pub enum MergeVirtualBranchUpstreamError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<MergeVirtualBranchUpstreamError> for Error {
|
|
||||||
fn from(value: MergeVirtualBranchUpstreamError) -> Self {
|
|
||||||
match value {
|
|
||||||
MergeVirtualBranchUpstreamError::BranchNotFound(error) => error.into(),
|
|
||||||
MergeVirtualBranchUpstreamError::Conflict(error) => error.into(),
|
|
||||||
MergeVirtualBranchUpstreamError::Other(error) => {
|
|
||||||
tracing::error!(?error, "merge virtual branch upstream error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for MergeVirtualBranchUpstreamError {
|
impl ErrorWithContext for MergeVirtualBranchUpstreamError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -368,28 +209,6 @@ pub enum CommitError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CommitError> for Error {
|
|
||||||
fn from(value: CommitError) -> Self {
|
|
||||||
match value {
|
|
||||||
CommitError::BranchNotFound(error) => error.into(),
|
|
||||||
CommitError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
CommitError::Conflicted(error) => error.into(),
|
|
||||||
CommitError::CommitHookRejected(error) => Error::UserError {
|
|
||||||
code: crate::error::Code::PreCommitHook,
|
|
||||||
message: error,
|
|
||||||
},
|
|
||||||
CommitError::CommitMsgHookRejected(error) => Error::UserError {
|
|
||||||
code: crate::error::Code::CommitMsgHook,
|
|
||||||
message: error,
|
|
||||||
},
|
|
||||||
CommitError::Other(error) => {
|
|
||||||
tracing::error!(?error, "commit error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for CommitError {
|
impl ErrorWithContext for CommitError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -419,20 +238,6 @@ pub enum PushError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PushError> for Error {
|
|
||||||
fn from(value: PushError) -> Self {
|
|
||||||
match value {
|
|
||||||
PushError::Remote(error) => error.into(),
|
|
||||||
PushError::BranchNotFound(error) => error.into(),
|
|
||||||
PushError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
PushError::Other(error) => {
|
|
||||||
tracing::error!(?error, "push error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for PushError {
|
impl ErrorWithContext for PushError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -454,22 +259,6 @@ pub enum IsRemoteBranchMergableError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<IsRemoteBranchMergableError> for Error {
|
|
||||||
fn from(value: IsRemoteBranchMergableError) -> Self {
|
|
||||||
match value {
|
|
||||||
IsRemoteBranchMergableError::BranchNotFound(name) => Error::UserError {
|
|
||||||
message: format!("Remote branch {} not found", name),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
IsRemoteBranchMergableError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
IsRemoteBranchMergableError::Other(error) => {
|
|
||||||
tracing::error!(?error, "is remote branch mergable error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for IsRemoteBranchMergableError {
|
impl ErrorWithContext for IsRemoteBranchMergableError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -492,19 +281,6 @@ pub enum IsVirtualBranchMergeable {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<IsVirtualBranchMergeable> for Error {
|
|
||||||
fn from(value: IsVirtualBranchMergeable) -> Self {
|
|
||||||
match value {
|
|
||||||
IsVirtualBranchMergeable::BranchNotFound(error) => error.into(),
|
|
||||||
IsVirtualBranchMergeable::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
IsVirtualBranchMergeable::Other(error) => {
|
|
||||||
tracing::error!(?error, "is remote branch mergable error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for IsVirtualBranchMergeable {
|
impl ErrorWithContext for IsVirtualBranchMergeable {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -520,15 +296,6 @@ pub struct ForcePushNotAllowed {
|
|||||||
pub project_id: ProjectId,
|
pub project_id: ProjectId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ForcePushNotAllowed> for Error {
|
|
||||||
fn from(_value: ForcePushNotAllowed) -> Self {
|
|
||||||
Error::UserError {
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
message: "Action will lead to force pushing, which is not allowed for this".to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ForcePushNotAllowed {
|
impl ForcePushNotAllowed {
|
||||||
fn to_context(&self) -> error::Context {
|
fn to_context(&self) -> error::Context {
|
||||||
error::Context::new_static(
|
error::Context::new_static(
|
||||||
@ -556,29 +323,6 @@ pub enum AmendError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AmendError> for Error {
|
|
||||||
fn from(value: AmendError) -> Self {
|
|
||||||
match value {
|
|
||||||
AmendError::ForcePushNotAllowed(error) => error.into(),
|
|
||||||
AmendError::Conflict(error) => error.into(),
|
|
||||||
AmendError::BranchNotFound(error) => error.into(),
|
|
||||||
AmendError::BranchHasNoCommits => Error::UserError {
|
|
||||||
message: "Branch has no commits - there is nothing to amend to".to_string(),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
AmendError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
AmendError::TargetOwnerhshipNotFound(_) => Error::UserError {
|
|
||||||
message: "target ownership not found".to_string(),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
AmendError::Other(error) => {
|
|
||||||
tracing::error!(?error, "amend error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for AmendError {
|
impl ErrorWithContext for AmendError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -610,26 +354,6 @@ pub enum CherryPickError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CherryPickError> for Error {
|
|
||||||
fn from(value: CherryPickError) -> Self {
|
|
||||||
match value {
|
|
||||||
CherryPickError::NotApplied => Error::UserError {
|
|
||||||
message: "can not cherry pick non applied branch".to_string(),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
CherryPickError::Conflict(error) => error.into(),
|
|
||||||
CherryPickError::CommitNotFound(oid) => Error::UserError {
|
|
||||||
message: format!("commit {oid} not found"),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
CherryPickError::Other(error) => {
|
|
||||||
tracing::error!(?error, "cherry pick error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for CherryPickError {
|
impl ErrorWithContext for CherryPickError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -663,29 +387,6 @@ pub enum SquashError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SquashError> for Error {
|
|
||||||
fn from(value: SquashError) -> Self {
|
|
||||||
match value {
|
|
||||||
SquashError::ForcePushNotAllowed(error) => error.into(),
|
|
||||||
SquashError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
SquashError::BranchNotFound(error) => error.into(),
|
|
||||||
SquashError::Conflict(error) => error.into(),
|
|
||||||
SquashError::CantSquashRootCommit => Error::UserError {
|
|
||||||
message: "can not squash root branch commit".to_string(),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
SquashError::CommitNotFound(oid) => Error::UserError {
|
|
||||||
message: format!("commit {oid} not found"),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
SquashError::Other(error) => {
|
|
||||||
tracing::error!(?error, "squash error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for SquashError {
|
impl ErrorWithContext for SquashError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -715,19 +416,6 @@ pub enum FetchFromTargetError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FetchFromTargetError> for Error {
|
|
||||||
fn from(value: FetchFromTargetError) -> Self {
|
|
||||||
match value {
|
|
||||||
FetchFromTargetError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
FetchFromTargetError::Remote(error) => error.into(),
|
|
||||||
FetchFromTargetError::Other(error) => {
|
|
||||||
tracing::error!(?error, "fetch from target error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for FetchFromTargetError {
|
impl ErrorWithContext for FetchFromTargetError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
match self {
|
match self {
|
||||||
@ -756,29 +444,6 @@ pub enum UpdateCommitMessageError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<UpdateCommitMessageError> for Error {
|
|
||||||
fn from(value: UpdateCommitMessageError) -> Self {
|
|
||||||
match value {
|
|
||||||
UpdateCommitMessageError::ForcePushNotAllowed(error) => error.into(),
|
|
||||||
UpdateCommitMessageError::EmptyMessage => Error::UserError {
|
|
||||||
message: "Commit message can not be empty".to_string(),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
UpdateCommitMessageError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
UpdateCommitMessageError::CommitNotFound(oid) => Error::UserError {
|
|
||||||
message: format!("Commit {} not found", oid),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
UpdateCommitMessageError::BranchNotFound(error) => error.into(),
|
|
||||||
UpdateCommitMessageError::Conflict(error) => error.into(),
|
|
||||||
UpdateCommitMessageError::Other(error) => {
|
|
||||||
tracing::error!(?error, "update commit message error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for UpdateCommitMessageError {
|
impl ErrorWithContext for UpdateCommitMessageError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -807,25 +472,6 @@ pub enum SetBaseBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SetBaseBranchError> for Error {
|
|
||||||
fn from(value: SetBaseBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
SetBaseBranchError::DirtyWorkingDirectory => Error::UserError {
|
|
||||||
message: "Current HEAD is dirty.".to_string(),
|
|
||||||
code: crate::error::Code::ProjectConflict,
|
|
||||||
},
|
|
||||||
SetBaseBranchError::BranchNotFound(name) => Error::UserError {
|
|
||||||
message: format!("remote branch '{}' not found", name),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
SetBaseBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "set base branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for SetBaseBranchError {
|
impl ErrorWithContext for SetBaseBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -851,19 +497,6 @@ pub enum UpdateBaseBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<UpdateBaseBranchError> for Error {
|
|
||||||
fn from(value: UpdateBaseBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
UpdateBaseBranchError::Conflict(error) => error.into(),
|
|
||||||
UpdateBaseBranchError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
UpdateBaseBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "update base branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for UpdateBaseBranchError {
|
impl ErrorWithContext for UpdateBaseBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -890,28 +523,6 @@ pub enum MoveCommitError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<MoveCommitError> for crate::error::Error {
|
|
||||||
fn from(value: MoveCommitError) -> Self {
|
|
||||||
match value {
|
|
||||||
MoveCommitError::SourceLocked => Error::UserError {
|
|
||||||
message: "Source branch contains hunks locked to the target commit".to_string(),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
MoveCommitError::Conflicted(error) => error.into(),
|
|
||||||
MoveCommitError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
MoveCommitError::BranchNotFound(error) => error.into(),
|
|
||||||
MoveCommitError::CommitNotFound(oid) => Error::UserError {
|
|
||||||
message: format!("Commit {} not found", oid),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
MoveCommitError::Other(error) => {
|
|
||||||
tracing::error!(?error, "move commit to vbranch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for MoveCommitError {
|
impl ErrorWithContext for MoveCommitError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -944,29 +555,6 @@ pub enum CreateVirtualBranchFromBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<CreateVirtualBranchFromBranchError> for Error {
|
|
||||||
fn from(value: CreateVirtualBranchFromBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
CreateVirtualBranchFromBranchError::ApplyBranch(error) => error.into(),
|
|
||||||
CreateVirtualBranchFromBranchError::CantMakeBranchFromDefaultTarget => {
|
|
||||||
Error::UserError {
|
|
||||||
message: "Can not create a branch from default target".to_string(),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CreateVirtualBranchFromBranchError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
CreateVirtualBranchFromBranchError::BranchNotFound(name) => Error::UserError {
|
|
||||||
message: format!("Branch {} not found", name),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
CreateVirtualBranchFromBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "create virtual branch from branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for CreateVirtualBranchFromBranchError {
|
impl ErrorWithContext for CreateVirtualBranchFromBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -991,15 +579,6 @@ pub struct ProjectConflict {
|
|||||||
pub project_id: ProjectId,
|
pub project_id: ProjectId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ProjectConflict> for Error {
|
|
||||||
fn from(value: ProjectConflict) -> Self {
|
|
||||||
Error::UserError {
|
|
||||||
code: crate::error::Code::ProjectConflict,
|
|
||||||
message: format!("project {} is in a conflicted state", value.project_id),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ProjectConflict {
|
impl ProjectConflict {
|
||||||
fn to_context(&self) -> error::Context {
|
fn to_context(&self) -> error::Context {
|
||||||
error::Context::new(
|
error::Context::new(
|
||||||
@ -1014,18 +593,6 @@ pub struct DefaultTargetNotSet {
|
|||||||
pub project_id: ProjectId,
|
pub project_id: ProjectId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<DefaultTargetNotSet> for Error {
|
|
||||||
fn from(value: DefaultTargetNotSet) -> Self {
|
|
||||||
Error::UserError {
|
|
||||||
code: crate::error::Code::ProjectConflict,
|
|
||||||
message: format!(
|
|
||||||
"project {} does not have a default target set",
|
|
||||||
value.project_id
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DefaultTargetNotSet {
|
impl DefaultTargetNotSet {
|
||||||
fn to_context(&self) -> error::Context {
|
fn to_context(&self) -> error::Context {
|
||||||
error::Context::new(
|
error::Context::new(
|
||||||
@ -1044,15 +611,6 @@ pub struct BranchNotFound {
|
|||||||
pub branch_id: BranchId,
|
pub branch_id: BranchId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<BranchNotFound> for Error {
|
|
||||||
fn from(value: BranchNotFound) -> Self {
|
|
||||||
Error::UserError {
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
message: format!("branch {} not found", value.branch_id),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BranchNotFound {
|
impl BranchNotFound {
|
||||||
fn to_context(&self) -> error::Context {
|
fn to_context(&self) -> error::Context {
|
||||||
error::Context::new(
|
error::Context::new(
|
||||||
@ -1072,19 +630,6 @@ pub enum UpdateBranchError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<UpdateBranchError> for Error {
|
|
||||||
fn from(value: UpdateBranchError) -> Self {
|
|
||||||
match value {
|
|
||||||
UpdateBranchError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
UpdateBranchError::BranchNotFound(error) => error.into(),
|
|
||||||
UpdateBranchError::Other(error) => {
|
|
||||||
tracing::error!(?error, "update branch error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for UpdateBranchError {
|
impl ErrorWithContext for UpdateBranchError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
Some(match self {
|
Some(match self {
|
||||||
@ -1103,21 +648,6 @@ pub enum ListRemoteCommitFilesError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ListRemoteCommitFilesError> for Error {
|
|
||||||
fn from(value: ListRemoteCommitFilesError) -> Self {
|
|
||||||
match value {
|
|
||||||
ListRemoteCommitFilesError::CommitNotFound(oid) => Error::UserError {
|
|
||||||
message: format!("Commit {} not found", oid),
|
|
||||||
code: crate::error::Code::Branches,
|
|
||||||
},
|
|
||||||
ListRemoteCommitFilesError::Other(error) => {
|
|
||||||
tracing::error!(?error, "list remote commit files error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for ListRemoteCommitFilesError {
|
impl ErrorWithContext for ListRemoteCommitFilesError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
match self {
|
match self {
|
||||||
@ -1137,18 +667,6 @@ pub enum ListRemoteBranchesError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ListRemoteBranchesError> for Error {
|
|
||||||
fn from(value: ListRemoteBranchesError) -> Self {
|
|
||||||
match value {
|
|
||||||
ListRemoteBranchesError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
ListRemoteBranchesError::Other(error) => {
|
|
||||||
tracing::error!(?error, "list remote branches error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for ListRemoteBranchesError {
|
impl ErrorWithContext for ListRemoteBranchesError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
match self {
|
match self {
|
||||||
@ -1166,18 +684,6 @@ pub enum GetRemoteBranchDataError {
|
|||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<GetRemoteBranchDataError> for Error {
|
|
||||||
fn from(value: GetRemoteBranchDataError) -> Self {
|
|
||||||
match value {
|
|
||||||
GetRemoteBranchDataError::DefaultTargetNotSet(error) => error.into(),
|
|
||||||
GetRemoteBranchDataError::Other(error) => {
|
|
||||||
tracing::error!(?error, "get remote branch data error");
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ErrorWithContext for GetRemoteBranchDataError {
|
impl ErrorWithContext for GetRemoteBranchDataError {
|
||||||
fn context(&self) -> Option<Context> {
|
fn context(&self) -> Option<Context> {
|
||||||
match self {
|
match self {
|
||||||
|
@ -7,7 +7,7 @@ use std::{
|
|||||||
time, vec,
|
time, vec,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{bail, Context, Result};
|
use anyhow::{anyhow, bail, Context, Result};
|
||||||
use bstr::ByteSlice;
|
use bstr::ByteSlice;
|
||||||
use diffy::{apply, Patch};
|
use diffy::{apply, Patch};
|
||||||
use git2_hooks::HookResult;
|
use git2_hooks::HookResult;
|
||||||
@ -21,6 +21,7 @@ use super::{
|
|||||||
branch_to_remote_branch, context, errors, target, Iterator, RemoteBranch,
|
branch_to_remote_branch, context, errors, target, Iterator, RemoteBranch,
|
||||||
VirtualBranchesHandle,
|
VirtualBranchesHandle,
|
||||||
};
|
};
|
||||||
|
use crate::error::Error;
|
||||||
use crate::{
|
use crate::{
|
||||||
askpass::AskpassBroker,
|
askpass::AskpassBroker,
|
||||||
dedup::{dedup, dedup_fmt},
|
dedup::{dedup, dedup_fmt},
|
||||||
@ -37,12 +38,6 @@ use crate::{
|
|||||||
|
|
||||||
type AppliedStatuses = Vec<(branch::Branch, HashMap<PathBuf, Vec<diff::GitHunk>>)>;
|
type AppliedStatuses = Vec<(branch::Branch, HashMap<PathBuf, Vec<diff::GitHunk>>)>;
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum Error {
|
|
||||||
#[error("path contains invalid utf-8 characters: {0}")]
|
|
||||||
InvalidUnicodePath(PathBuf),
|
|
||||||
}
|
|
||||||
|
|
||||||
// this struct is a mapping to the view `Branch` type in Typescript
|
// this struct is a mapping to the view `Branch` type in Typescript
|
||||||
// found in src-tauri/src/routes/repo/[project_id]/types.ts
|
// found in src-tauri/src/routes/repo/[project_id]/types.ts
|
||||||
// it holds a materialized view for presentation purposes of the Branch struct in Rust
|
// it holds a materialized view for presentation purposes of the Branch struct in Rust
|
||||||
@ -1839,7 +1834,7 @@ pub fn delete_branch(
|
|||||||
gb_repository: &gb_repository::Repository,
|
gb_repository: &gb_repository::Repository,
|
||||||
project_repository: &project_repository::Repository,
|
project_repository: &project_repository::Repository,
|
||||||
branch_id: &BranchId,
|
branch_id: &BranchId,
|
||||||
) -> Result<(), errors::DeleteBranchError> {
|
) -> Result<(), Error> {
|
||||||
let current_session = gb_repository
|
let current_session = gb_repository
|
||||||
.get_or_create_current_session()
|
.get_or_create_current_session()
|
||||||
.context("failed to get or create currnt session")?;
|
.context("failed to get or create currnt session")?;
|
||||||
@ -2503,7 +2498,9 @@ pub fn write_tree_onto_tree(
|
|||||||
let blob_oid = git_repository.blob(
|
let blob_oid = git_repository.blob(
|
||||||
link_target
|
link_target
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or_else(|| Error::InvalidUnicodePath(link_target.into()))?
|
.ok_or_else(|| {
|
||||||
|
anyhow!("path contains invalid utf-8 characters: {link_target:?}")
|
||||||
|
})?
|
||||||
.as_bytes(),
|
.as_bytes(),
|
||||||
)?;
|
)?;
|
||||||
builder.upsert(rel_path, blob_oid, filemode);
|
builder.upsert(rel_path, blob_oid, filemode);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
use std::path;
|
use std::path;
|
||||||
|
|
||||||
use super::Zipper;
|
use super::Zipper;
|
||||||
@ -28,12 +28,12 @@ impl Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn archive(&self, project_id: &ProjectId) -> Result<path::PathBuf, Error2> {
|
pub fn archive(&self, project_id: &ProjectId) -> Result<path::PathBuf, Error> {
|
||||||
let project = self.projects_controller.get(project_id)?;
|
let project = self.projects_controller.get(project_id)?;
|
||||||
self.zipper.zip(project.path).map_err(Into::into)
|
self.zipper.zip(project.path).map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data_archive(&self, project_id: &ProjectId) -> Result<path::PathBuf, Error2> {
|
pub fn data_archive(&self, project_id: &ProjectId) -> Result<path::PathBuf, Error> {
|
||||||
let project = self.projects_controller.get(project_id)?;
|
let project = self.projects_controller.get(project_id)?;
|
||||||
self.zipper
|
self.zipper
|
||||||
.zip(
|
.zip(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::{collections::HashMap, path};
|
use std::{collections::HashMap, path};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use gitbutler_core::error::Error2 as CoreError;
|
use gitbutler_core::error::Error as CoreError;
|
||||||
use gitbutler_core::{
|
use gitbutler_core::{
|
||||||
askpass::AskpassBroker,
|
askpass::AskpassBroker,
|
||||||
gb_repository, git,
|
gb_repository, git,
|
||||||
@ -13,7 +13,7 @@ use gitbutler_core::{
|
|||||||
virtual_branches::BranchId,
|
virtual_branches::BranchId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
use crate::watcher;
|
use crate::watcher;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -69,7 +69,7 @@ impl App {
|
|||||||
project_id: &ProjectId,
|
project_id: &ProjectId,
|
||||||
session_id: &SessionId,
|
session_id: &SessionId,
|
||||||
paths: Option<&[&path::Path]>,
|
paths: Option<&[&path::Path]>,
|
||||||
) -> Result<HashMap<path::PathBuf, reader::Content>, Error2> {
|
) -> Result<HashMap<path::PathBuf, reader::Content>, Error> {
|
||||||
let session = self
|
let session = self
|
||||||
.sessions_database
|
.sessions_database
|
||||||
.get_by_project_id_id(project_id, session_id)
|
.get_by_project_id_id(project_id, session_id)
|
||||||
@ -79,9 +79,9 @@ impl App {
|
|||||||
let project = self
|
let project = self
|
||||||
.projects
|
.projects
|
||||||
.get(project_id)
|
.get(project_id)
|
||||||
.map_err(Error2::from_error_with_context)?;
|
.map_err(Error::from_error_with_context)?;
|
||||||
let project_repository = project_repository::Repository::open(&project)
|
let project_repository = project_repository::Repository::open(&project)
|
||||||
.map_err(Error2::from_error_with_context)?;
|
.map_err(Error::from_error_with_context)?;
|
||||||
let gb_repo = gb_repository::Repository::open(
|
let gb_repo = gb_repository::Repository::open(
|
||||||
&self.local_data_dir,
|
&self.local_data_dir,
|
||||||
&project_repository,
|
&project_repository,
|
||||||
|
@ -11,7 +11,7 @@ use gitbutler_core::{
|
|||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
use crate::{app, watcher};
|
use crate::{app, watcher};
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
@ -21,7 +21,7 @@ pub async fn list_session_files(
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
session_id: SessionId,
|
session_id: SessionId,
|
||||||
paths: Option<Vec<&path::Path>>,
|
paths: Option<Vec<&path::Path>>,
|
||||||
) -> Result<HashMap<path::PathBuf, reader::Content>, Error2> {
|
) -> Result<HashMap<path::PathBuf, reader::Content>, Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let files = app.list_session_files(&project_id, &session_id, paths.as_deref())?;
|
let files = app.list_session_files(&project_id, &session_id, paths.as_deref())?;
|
||||||
Ok(files)
|
Ok(files)
|
||||||
@ -32,7 +32,7 @@ pub async fn list_session_files(
|
|||||||
pub async fn git_remote_branches(
|
pub async fn git_remote_branches(
|
||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
) -> Result<Vec<git::RemoteRefname>, Error2> {
|
) -> Result<Vec<git::RemoteRefname>, Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let branches = app.git_remote_branches(&project_id)?;
|
let branches = app.git_remote_branches(&project_id)?;
|
||||||
Ok(branches)
|
Ok(branches)
|
||||||
@ -45,7 +45,7 @@ pub async fn git_test_push(
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
remote_name: &str,
|
remote_name: &str,
|
||||||
branch_name: &str,
|
branch_name: &str,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let helper = handle.state::<gitbutler_core::git::credentials::Helper>();
|
let helper = handle.state::<gitbutler_core::git::credentials::Helper>();
|
||||||
let askpass_broker = handle
|
let askpass_broker = handle
|
||||||
@ -68,7 +68,7 @@ pub async fn git_test_fetch(
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
remote_name: &str,
|
remote_name: &str,
|
||||||
action: Option<String>,
|
action: Option<String>,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let helper = handle.state::<gitbutler_core::git::credentials::Helper>();
|
let helper = handle.state::<gitbutler_core::git::credentials::Helper>();
|
||||||
let askpass_broker = handle
|
let askpass_broker = handle
|
||||||
@ -88,14 +88,14 @@ pub async fn git_test_fetch(
|
|||||||
pub async fn git_index_size(
|
pub async fn git_index_size(
|
||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
) -> Result<usize, Error2> {
|
) -> Result<usize, Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
Ok(app.git_index_size(&project_id).expect("git index size"))
|
Ok(app.git_index_size(&project_id).expect("git index size"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn git_head(handle: tauri::AppHandle, project_id: ProjectId) -> Result<String, Error2> {
|
pub async fn git_head(handle: tauri::AppHandle, project_id: ProjectId) -> Result<String, Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
let head = app.git_head(&project_id)?;
|
let head = app.git_head(&project_id)?;
|
||||||
Ok(head)
|
Ok(head)
|
||||||
@ -103,7 +103,7 @@ pub async fn git_head(handle: tauri::AppHandle, project_id: ProjectId) -> Result
|
|||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn delete_all_data(handle: tauri::AppHandle) -> Result<(), Error2> {
|
pub async fn delete_all_data(handle: tauri::AppHandle) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
app.delete_all_data().await?;
|
app.delete_all_data().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -115,7 +115,7 @@ pub async fn mark_resolved(
|
|||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let app = handle.state::<app::App>();
|
let app = handle.state::<app::App>();
|
||||||
app.mark_resolved(&project_id, path)?;
|
app.mark_resolved(&project_id, path)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -127,7 +127,7 @@ pub async fn git_set_global_config(
|
|||||||
_handle: tauri::AppHandle,
|
_handle: tauri::AppHandle,
|
||||||
key: &str,
|
key: &str,
|
||||||
value: &str,
|
value: &str,
|
||||||
) -> Result<String, Error2> {
|
) -> Result<String, Error> {
|
||||||
let result = app::App::git_set_global_config(key, value)?;
|
let result = app::App::git_set_global_config(key, value)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
@ -137,14 +137,14 @@ pub async fn git_set_global_config(
|
|||||||
pub async fn git_get_global_config(
|
pub async fn git_get_global_config(
|
||||||
_handle: tauri::AppHandle,
|
_handle: tauri::AppHandle,
|
||||||
key: &str,
|
key: &str,
|
||||||
) -> Result<Option<String>, Error2> {
|
) -> Result<Option<String>, Error> {
|
||||||
let result = app::App::git_get_global_config(key)?;
|
let result = app::App::git_get_global_config(key)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn project_flush_and_push(handle: tauri::AppHandle, id: ProjectId) -> Result<(), Error2> {
|
pub async fn project_flush_and_push(handle: tauri::AppHandle, id: ProjectId) -> Result<(), Error> {
|
||||||
let users = handle.state::<users::Controller>().inner().clone();
|
let users = handle.state::<users::Controller>().inner().clone();
|
||||||
let projects = handle.state::<projects::Controller>().inner().clone();
|
let projects = handle.state::<projects::Controller>().inner().clone();
|
||||||
let local_data_dir = handle
|
let local_data_dir = handle
|
||||||
@ -155,7 +155,7 @@ pub async fn project_flush_and_push(handle: tauri::AppHandle, id: ProjectId) ->
|
|||||||
let project = projects.get(&id).context("failed to get project")?;
|
let project = projects.get(&id).context("failed to get project")?;
|
||||||
let user = users.get_user()?;
|
let user = users.get_user()?;
|
||||||
let project_repository =
|
let project_repository =
|
||||||
project_repository::Repository::open(&project).map_err(Error2::from_error_with_context)?;
|
project_repository::Repository::open(&project).map_err(Error::from_error_with_context)?;
|
||||||
let gb_repo =
|
let gb_repo =
|
||||||
gb_repository::Repository::open(&local_data_dir, &project_repository, user.as_ref())
|
gb_repository::Repository::open(&local_data_dir, &project_repository, user.as_ref())
|
||||||
.context("failed to open repository")?;
|
.context("failed to open repository")?;
|
||||||
|
@ -4,10 +4,11 @@ pub mod commands {
|
|||||||
|
|
||||||
use gitbutler_core::deltas::{Controller, Delta};
|
use gitbutler_core::deltas::{Controller, Delta};
|
||||||
use gitbutler_core::error;
|
use gitbutler_core::error;
|
||||||
|
use gitbutler_core::error::Code;
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::{Code, Error2};
|
use crate::error::Error;
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
@ -16,7 +17,7 @@ pub mod commands {
|
|||||||
project_id: &str,
|
project_id: &str,
|
||||||
session_id: &str,
|
session_id: &str,
|
||||||
paths: Option<Vec<&str>>,
|
paths: Option<Vec<&str>>,
|
||||||
) -> Result<HashMap<String, Vec<Delta>>, Error2> {
|
) -> Result<HashMap<String, Vec<Delta>>, Error> {
|
||||||
let session_id = session_id.parse().context(error::Context::new_static(
|
let session_id = session_id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed session id",
|
"Malformed session id",
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
pub(crate) use frontend::Error2;
|
pub(crate) use frontend::Error;
|
||||||
pub use gitbutler_core::error::Code;
|
|
||||||
pub(crate) use legacy::Error;
|
|
||||||
|
|
||||||
mod frontend {
|
mod frontend {
|
||||||
use anyhow::Error;
|
|
||||||
use gitbutler_core::error::{into_anyhow, AnyhowContextExt, ErrorWithContext};
|
use gitbutler_core::error::{into_anyhow, AnyhowContextExt, ErrorWithContext};
|
||||||
use serde::{ser::SerializeMap, Serialize};
|
use serde::{ser::SerializeMap, Serialize};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
@ -11,21 +8,21 @@ mod frontend {
|
|||||||
/// An error type for serialization, dynamically extracting context information during serialization,
|
/// An error type for serialization, dynamically extracting context information during serialization,
|
||||||
/// meant for consumption by the frontend.
|
/// meant for consumption by the frontend.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Error2(anyhow::Error);
|
pub struct Error(anyhow::Error);
|
||||||
|
|
||||||
impl From<anyhow::Error> for Error2 {
|
impl From<anyhow::Error> for Error {
|
||||||
fn from(value: Error) -> Self {
|
fn from(value: anyhow::Error) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<gitbutler_core::error::Error2> for Error2 {
|
impl From<gitbutler_core::error::Error> for Error {
|
||||||
fn from(value: gitbutler_core::error::Error2) -> Self {
|
fn from(value: gitbutler_core::error::Error) -> Self {
|
||||||
Self(value.into())
|
Self(value.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error2 {
|
impl Error {
|
||||||
/// Convert an error with context to our type.
|
/// Convert an error with context to our type.
|
||||||
///
|
///
|
||||||
/// Note that this is only needed as trait specialization isn't working well enough yet.
|
/// Note that this is only needed as trait specialization isn't working well enough yet.
|
||||||
@ -34,7 +31,7 @@ mod frontend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for Error2 {
|
impl Serialize for Error {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
@ -61,7 +58,7 @@ mod frontend {
|
|||||||
use gitbutler_core::error::{Code, Context};
|
use gitbutler_core::error::{Code, Context};
|
||||||
|
|
||||||
fn json(err: anyhow::Error) -> String {
|
fn json(err: anyhow::Error) -> String {
|
||||||
serde_json::to_string(&Error2(err)).unwrap()
|
serde_json::to_string(&Error(err)).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -130,62 +127,3 @@ mod frontend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[deprecated(
|
|
||||||
// note = "the types in the error::legacy::* module are deprecated; use error::gb::Error and error::gb::Result instead"
|
|
||||||
//)]
|
|
||||||
mod legacy {
|
|
||||||
use gitbutler_core::error::Code;
|
|
||||||
use gitbutler_core::project_repository;
|
|
||||||
use serde::{ser::SerializeMap, Serialize};
|
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum Error {
|
|
||||||
#[error("[{code}]: {message}")]
|
|
||||||
UserError { code: Code, message: String },
|
|
||||||
#[error("[errors.unknown]: Something went wrong")]
|
|
||||||
Unknown,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Error {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
let (code, message) = match self {
|
|
||||||
Error::UserError { code, message } => (code.to_string(), message.to_string()),
|
|
||||||
Error::Unknown => (
|
|
||||||
Code::Unknown.to_string(),
|
|
||||||
"Something went wrong".to_string(),
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut map = serializer.serialize_map(Some(2))?;
|
|
||||||
map.serialize_entry("code", &code)?;
|
|
||||||
map.serialize_entry("message", &message)?;
|
|
||||||
map.end()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<anyhow::Error> for Error {
|
|
||||||
fn from(error: anyhow::Error) -> Self {
|
|
||||||
tracing::error!(?error);
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<project_repository::OpenError> for Error {
|
|
||||||
fn from(value: project_repository::OpenError) -> Self {
|
|
||||||
match value {
|
|
||||||
project_repository::OpenError::NotFound(path) => Error::UserError {
|
|
||||||
code: Code::Projects,
|
|
||||||
message: format!("{} not found", path.display()),
|
|
||||||
},
|
|
||||||
project_repository::OpenError::Other(error) => {
|
|
||||||
tracing::error!(?error);
|
|
||||||
Error::Unknown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,7 @@ pub mod commands {
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
|
|
||||||
const GITHUB_CLIENT_ID: &str = "cd51880daa675d9e6452";
|
const GITHUB_CLIENT_ID: &str = "cd51880daa675d9e6452";
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ pub mod commands {
|
|||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub async fn init_device_oauth() -> Result<Verification, Error2> {
|
pub async fn init_device_oauth() -> Result<Verification, Error> {
|
||||||
let mut req_body = HashMap::new();
|
let mut req_body = HashMap::new();
|
||||||
req_body.insert("client_id", GITHUB_CLIENT_ID);
|
req_body.insert("client_id", GITHUB_CLIENT_ID);
|
||||||
req_body.insert("scope", "repo");
|
req_body.insert("scope", "repo");
|
||||||
@ -46,7 +46,7 @@ pub mod commands {
|
|||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub async fn check_auth_status(device_code: &str) -> Result<String, Error2> {
|
pub async fn check_auth_status(device_code: &str) -> Result<String, Error> {
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
|
#[derive(Debug, Deserialize, Serialize, Clone, Default)]
|
||||||
struct AccessTokenContainer {
|
struct AccessTokenContainer {
|
||||||
access_token: String,
|
access_token: String,
|
||||||
|
@ -3,11 +3,11 @@ pub mod commands {
|
|||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn get_public_key(handle: tauri::AppHandle) -> Result<PublicKey, Error2> {
|
pub async fn get_public_key(handle: tauri::AppHandle) -> Result<PublicKey, Error> {
|
||||||
handle
|
handle
|
||||||
.state::<controller::Controller>()
|
.state::<controller::Controller>()
|
||||||
.get_or_create()
|
.get_or_create()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use gitbutler_core::error;
|
use gitbutler_core::error;
|
||||||
|
use gitbutler_core::error::Code;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tauri::{
|
use tauri::{
|
||||||
AppHandle, CustomMenuItem, Manager, Menu, MenuEntry, PackageInfo, Runtime, Submenu,
|
AppHandle, CustomMenuItem, Manager, Menu, MenuEntry, PackageInfo, Runtime, Submenu,
|
||||||
@ -7,7 +8,7 @@ use tauri::{
|
|||||||
};
|
};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::{Code, Error2};
|
use crate::error::Error;
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
@ -15,7 +16,7 @@ pub async fn menu_item_set_enabled(
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
menu_item_id: &str,
|
menu_item_id: &str,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let window = handle
|
let window = handle
|
||||||
.get_window("main")
|
.get_window("main")
|
||||||
.expect("main window always present");
|
.expect("main window always present");
|
||||||
|
@ -3,23 +3,24 @@ pub mod commands {
|
|||||||
use std::path;
|
use std::path;
|
||||||
|
|
||||||
use gitbutler_core::error;
|
use gitbutler_core::error;
|
||||||
|
use gitbutler_core::error::Code;
|
||||||
use gitbutler_core::projects::{self, controller::Controller};
|
use gitbutler_core::projects::{self, controller::Controller};
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::{Code, Error2};
|
use crate::error::Error;
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn update_project(
|
pub async fn update_project(
|
||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
project: projects::UpdateRequest,
|
project: projects::UpdateRequest,
|
||||||
) -> Result<projects::Project, Error2> {
|
) -> Result<projects::Project, Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.update(&project)
|
.update(&project)
|
||||||
.await
|
.await
|
||||||
.map_err(Error2::from_error_with_context)
|
.map_err(Error::from_error_with_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
@ -27,11 +28,11 @@ pub mod commands {
|
|||||||
pub async fn add_project(
|
pub async fn add_project(
|
||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
path: &path::Path,
|
path: &path::Path,
|
||||||
) -> Result<projects::Project, Error2> {
|
) -> Result<projects::Project, Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.add(path)
|
.add(path)
|
||||||
.map_err(Error2::from_error_with_context)
|
.map_err(Error::from_error_with_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
@ -39,7 +40,7 @@ pub mod commands {
|
|||||||
pub async fn get_project(
|
pub async fn get_project(
|
||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<projects::Project, Error2> {
|
) -> Result<projects::Project, Error> {
|
||||||
let id = id.parse().context(error::Context::new_static(
|
let id = id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed project id",
|
"Malformed project id",
|
||||||
@ -47,18 +48,18 @@ pub mod commands {
|
|||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.get(&id)
|
.get(&id)
|
||||||
.map_err(Error2::from_error_with_context)
|
.map_err(Error::from_error_with_context)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn list_projects(handle: tauri::AppHandle) -> Result<Vec<projects::Project>, Error2> {
|
pub async fn list_projects(handle: tauri::AppHandle) -> Result<Vec<projects::Project>, Error> {
|
||||||
handle.state::<Controller>().list().map_err(Into::into)
|
handle.state::<Controller>().list().map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn delete_project(handle: tauri::AppHandle, id: &str) -> Result<(), Error2> {
|
pub async fn delete_project(handle: tauri::AppHandle, id: &str) -> Result<(), Error> {
|
||||||
let id = id.parse().context(error::Context::new_static(
|
let id = id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed project id",
|
"Malformed project id",
|
||||||
@ -76,7 +77,7 @@ pub mod commands {
|
|||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
id: &str,
|
id: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
) -> Result<Option<String>, Error2> {
|
) -> Result<Option<String>, Error> {
|
||||||
let id = id.parse().context(error::Context::new_static(
|
let id = id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed project id",
|
"Malformed project id",
|
||||||
@ -94,7 +95,7 @@ pub mod commands {
|
|||||||
id: &str,
|
id: &str,
|
||||||
key: &str,
|
key: &str,
|
||||||
value: &str,
|
value: &str,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let id = id.parse().context(error::Context::new_static(
|
let id = id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed project id",
|
"Malformed project id",
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
pub mod commands {
|
pub mod commands {
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use gitbutler_core::error;
|
use gitbutler_core::error;
|
||||||
|
use gitbutler_core::error::Code;
|
||||||
use gitbutler_core::sessions::{Controller, Session};
|
use gitbutler_core::sessions::{Controller, Session};
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::{Code, Error2};
|
use crate::error::Error;
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
@ -13,7 +14,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: &str,
|
project_id: &str,
|
||||||
earliest_timestamp_ms: Option<u128>,
|
earliest_timestamp_ms: Option<u128>,
|
||||||
) -> Result<Vec<Session>, Error2> {
|
) -> Result<Vec<Session>, Error> {
|
||||||
let project_id = project_id.parse().context(error::Context::new_static(
|
let project_id = project_id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed project id",
|
"Malformed project id",
|
||||||
|
@ -6,12 +6,12 @@ pub mod commands {
|
|||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
use crate::sentry;
|
use crate::sentry;
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn get_user(handle: AppHandle) -> Result<Option<User>, Error2> {
|
pub async fn get_user(handle: AppHandle) -> Result<Option<User>, Error> {
|
||||||
let app = handle.state::<Controller>();
|
let app = handle.state::<Controller>();
|
||||||
let proxy = handle.state::<assets::Proxy>();
|
let proxy = handle.state::<assets::Proxy>();
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ pub mod commands {
|
|||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn set_user(handle: AppHandle, user: User) -> Result<User, Error2> {
|
pub async fn set_user(handle: AppHandle, user: User) -> Result<User, Error> {
|
||||||
let app = handle.state::<Controller>();
|
let app = handle.state::<Controller>();
|
||||||
let proxy = handle.state::<assets::Proxy>();
|
let proxy = handle.state::<assets::Proxy>();
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ pub mod commands {
|
|||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn delete_user(handle: AppHandle) -> Result<(), Error2> {
|
pub async fn delete_user(handle: AppHandle) -> Result<(), Error> {
|
||||||
let app = handle.state::<Controller>();
|
let app = handle.state::<Controller>();
|
||||||
|
|
||||||
app.delete_user()?;
|
app.delete_user()?;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pub mod commands {
|
pub mod commands {
|
||||||
use crate::error::Error2;
|
use crate::error::Error;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use gitbutler_core::{
|
use gitbutler_core::{
|
||||||
askpass::AskpassBroker,
|
askpass::AskpassBroker,
|
||||||
@ -27,7 +27,7 @@ pub mod commands {
|
|||||||
message: &str,
|
message: &str,
|
||||||
ownership: Option<BranchOwnershipClaims>,
|
ownership: Option<BranchOwnershipClaims>,
|
||||||
run_hooks: bool,
|
run_hooks: bool,
|
||||||
) -> Result<git::Oid, Error2> {
|
) -> Result<git::Oid, Error> {
|
||||||
let oid = handle
|
let oid = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.create_commit(&project_id, &branch, message, ownership.as_ref(), run_hooks)
|
.create_commit(&project_id, &branch, message, ownership.as_ref(), run_hooks)
|
||||||
@ -43,7 +43,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_ids: Vec<BranchId>,
|
branch_ids: Vec<BranchId>,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.save_vbranches_state(&project_id, branch_ids)
|
.save_vbranches_state(&project_id, branch_ids)
|
||||||
@ -56,7 +56,7 @@ pub mod commands {
|
|||||||
pub async fn list_virtual_branches(
|
pub async fn list_virtual_branches(
|
||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
) -> Result<VirtualBranches, Error2> {
|
) -> Result<VirtualBranches, Error> {
|
||||||
let (branches, uses_diff_context, skipped_files) = handle
|
let (branches, uses_diff_context, skipped_files) = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.list_virtual_branches(&project_id)
|
.list_virtual_branches(&project_id)
|
||||||
@ -89,7 +89,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: branch::BranchCreateRequest,
|
branch: branch::BranchCreateRequest,
|
||||||
) -> Result<BranchId, Error2> {
|
) -> Result<BranchId, Error> {
|
||||||
let branch_id = handle
|
let branch_id = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.create_virtual_branch(&project_id, &branch)
|
.create_virtual_branch(&project_id, &branch)
|
||||||
@ -104,7 +104,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: git::Refname,
|
branch: git::Refname,
|
||||||
) -> Result<BranchId, Error2> {
|
) -> Result<BranchId, Error> {
|
||||||
let branch_id = handle
|
let branch_id = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.create_virtual_branch_from_branch(&project_id, &branch)
|
.create_virtual_branch_from_branch(&project_id, &branch)
|
||||||
@ -119,7 +119,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: BranchId,
|
branch: BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.merge_virtual_branch_upstream(&project_id, &branch)
|
.merge_virtual_branch_upstream(&project_id, &branch)
|
||||||
@ -133,7 +133,7 @@ pub mod commands {
|
|||||||
pub async fn get_base_branch_data(
|
pub async fn get_base_branch_data(
|
||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
) -> Result<Option<BaseBranch>, Error2> {
|
) -> Result<Option<BaseBranch>, Error> {
|
||||||
if let Some(base_branch) = handle
|
if let Some(base_branch) = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.get_base_branch_data(&project_id)
|
.get_base_branch_data(&project_id)
|
||||||
@ -153,7 +153,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: &str,
|
branch: &str,
|
||||||
) -> Result<BaseBranch, Error2> {
|
) -> Result<BaseBranch, Error> {
|
||||||
let branch_name = format!("refs/remotes/{}", branch)
|
let branch_name = format!("refs/remotes/{}", branch)
|
||||||
.parse()
|
.parse()
|
||||||
.context("Invalid branch name")?;
|
.context("Invalid branch name")?;
|
||||||
@ -171,10 +171,7 @@ pub mod commands {
|
|||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn update_base_branch(
|
pub async fn update_base_branch(handle: AppHandle, project_id: ProjectId) -> Result<(), Error> {
|
||||||
handle: AppHandle,
|
|
||||||
project_id: ProjectId,
|
|
||||||
) -> Result<(), Error2> {
|
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.update_base_branch(&project_id)
|
.update_base_branch(&project_id)
|
||||||
@ -189,7 +186,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: branch::BranchUpdateRequest,
|
branch: branch::BranchUpdateRequest,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.update_virtual_branch(&project_id, branch)
|
.update_virtual_branch(&project_id, branch)
|
||||||
@ -205,7 +202,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.delete_virtual_branch(&project_id, &branch_id)
|
.delete_virtual_branch(&project_id, &branch_id)
|
||||||
@ -220,7 +217,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: BranchId,
|
branch: BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.apply_virtual_branch(&project_id, &branch)
|
.apply_virtual_branch(&project_id, &branch)
|
||||||
@ -235,7 +232,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: BranchId,
|
branch: BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.unapply_virtual_branch(&project_id, &branch)
|
.unapply_virtual_branch(&project_id, &branch)
|
||||||
@ -250,7 +247,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
ownership: BranchOwnershipClaims,
|
ownership: BranchOwnershipClaims,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.unapply_ownership(&project_id, &ownership)
|
.unapply_ownership(&project_id, &ownership)
|
||||||
@ -265,7 +262,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
files: &str,
|
files: &str,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
// convert files to Vec<String>
|
// convert files to Vec<String>
|
||||||
let files = files
|
let files = files
|
||||||
.split('\n')
|
.split('\n')
|
||||||
@ -286,7 +283,7 @@ pub mod commands {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
with_force: bool,
|
with_force: bool,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
let askpass_broker = handle.state::<AskpassBroker>();
|
let askpass_broker = handle.state::<AskpassBroker>();
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
@ -308,7 +305,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
) -> Result<bool, Error2> {
|
) -> Result<bool, Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.can_apply_virtual_branch(&project_id, &branch_id)
|
.can_apply_virtual_branch(&project_id, &branch_id)
|
||||||
@ -322,7 +319,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch: git::RemoteRefname,
|
branch: git::RemoteRefname,
|
||||||
) -> Result<bool, Error2> {
|
) -> Result<bool, Error> {
|
||||||
Ok(handle
|
Ok(handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.can_apply_remote_branch(&project_id, &branch)
|
.can_apply_remote_branch(&project_id, &branch)
|
||||||
@ -335,7 +332,7 @@ pub mod commands {
|
|||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
) -> Result<Vec<RemoteBranchFile>, Error2> {
|
) -> Result<Vec<RemoteBranchFile>, Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.list_remote_commit_files(&project_id, commit_oid)
|
.list_remote_commit_files(&project_id, commit_oid)
|
||||||
@ -350,7 +347,7 @@ pub mod commands {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
target_commit_oid: git::Oid,
|
target_commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.reset_virtual_branch(&project_id, &branch_id, target_commit_oid)
|
.reset_virtual_branch(&project_id, &branch_id, target_commit_oid)
|
||||||
@ -366,7 +363,7 @@ pub mod commands {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
target_commit_oid: git::Oid,
|
target_commit_oid: git::Oid,
|
||||||
) -> Result<Option<git::Oid>, Error2> {
|
) -> Result<Option<git::Oid>, Error> {
|
||||||
let oid = handle
|
let oid = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.cherry_pick(&project_id, &branch_id, target_commit_oid)
|
.cherry_pick(&project_id, &branch_id, target_commit_oid)
|
||||||
@ -382,7 +379,7 @@ pub mod commands {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
ownership: BranchOwnershipClaims,
|
ownership: BranchOwnershipClaims,
|
||||||
) -> Result<git::Oid, Error2> {
|
) -> Result<git::Oid, Error> {
|
||||||
let oid = handle
|
let oid = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.amend(&project_id, &branch_id, &ownership)
|
.amend(&project_id, &branch_id, &ownership)
|
||||||
@ -396,7 +393,7 @@ pub mod commands {
|
|||||||
pub async fn list_remote_branches(
|
pub async fn list_remote_branches(
|
||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
) -> Result<Vec<RemoteBranch>, Error2> {
|
) -> Result<Vec<RemoteBranch>, Error> {
|
||||||
let branches = handle
|
let branches = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.list_remote_branches(&project_id)
|
.list_remote_branches(&project_id)
|
||||||
@ -410,7 +407,7 @@ pub mod commands {
|
|||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
refname: git::Refname,
|
refname: git::Refname,
|
||||||
) -> Result<RemoteBranchData, Error2> {
|
) -> Result<RemoteBranchData, Error> {
|
||||||
let branch_data = handle
|
let branch_data = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.get_remote_branch_data(&project_id, &refname)
|
.get_remote_branch_data(&project_id, &refname)
|
||||||
@ -429,7 +426,7 @@ pub mod commands {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
target_commit_oid: git::Oid,
|
target_commit_oid: git::Oid,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.squash(&project_id, &branch_id, target_commit_oid)
|
.squash(&project_id, &branch_id, target_commit_oid)
|
||||||
@ -444,7 +441,7 @@ pub mod commands {
|
|||||||
handle: tauri::AppHandle,
|
handle: tauri::AppHandle,
|
||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
action: Option<String>,
|
action: Option<String>,
|
||||||
) -> Result<BaseBranch, Error2> {
|
) -> Result<BaseBranch, Error> {
|
||||||
let askpass_broker = handle.state::<AskpassBroker>().inner().clone();
|
let askpass_broker = handle.state::<AskpassBroker>().inner().clone();
|
||||||
let base_branch = handle
|
let base_branch = handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
@ -467,7 +464,7 @@ pub mod commands {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
target_branch_id: BranchId,
|
target_branch_id: BranchId,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.move_commit(&project_id, &target_branch_id, commit_oid)
|
.move_commit(&project_id, &target_branch_id, commit_oid)
|
||||||
@ -484,7 +481,7 @@ pub mod commands {
|
|||||||
branch_id: BranchId,
|
branch_id: BranchId,
|
||||||
commit_oid: git::Oid,
|
commit_oid: git::Oid,
|
||||||
message: &str,
|
message: &str,
|
||||||
) -> Result<(), Error2> {
|
) -> Result<(), Error> {
|
||||||
handle
|
handle
|
||||||
.state::<Controller>()
|
.state::<Controller>()
|
||||||
.update_commit_message(&project_id, &branch_id, commit_oid, message)
|
.update_commit_message(&project_id, &branch_id, commit_oid, message)
|
||||||
|
@ -4,18 +4,19 @@ pub mod commands {
|
|||||||
use std::path;
|
use std::path;
|
||||||
|
|
||||||
use gitbutler_core::error;
|
use gitbutler_core::error;
|
||||||
|
use gitbutler_core::error::Code;
|
||||||
use gitbutler_core::zip::controller;
|
use gitbutler_core::zip::controller;
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::error::{Code, Error2};
|
use crate::error::Error;
|
||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn get_project_archive_path(
|
pub async fn get_project_archive_path(
|
||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: &str,
|
project_id: &str,
|
||||||
) -> Result<path::PathBuf, Error2> {
|
) -> Result<path::PathBuf, Error> {
|
||||||
let project_id = project_id.parse().context(error::Context::new_static(
|
let project_id = project_id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed project id",
|
"Malformed project id",
|
||||||
@ -31,7 +32,7 @@ pub mod commands {
|
|||||||
pub async fn get_project_data_archive_path(
|
pub async fn get_project_data_archive_path(
|
||||||
handle: AppHandle,
|
handle: AppHandle,
|
||||||
project_id: &str,
|
project_id: &str,
|
||||||
) -> Result<path::PathBuf, Error2> {
|
) -> Result<path::PathBuf, Error> {
|
||||||
let project_id = project_id.parse().context(error::Context::new_static(
|
let project_id = project_id.parse().context(error::Context::new_static(
|
||||||
Code::Validation,
|
Code::Validation,
|
||||||
"Malformed project id",
|
"Malformed project id",
|
||||||
@ -44,7 +45,7 @@ pub mod commands {
|
|||||||
|
|
||||||
#[tauri::command(async)]
|
#[tauri::command(async)]
|
||||||
#[instrument(skip(handle))]
|
#[instrument(skip(handle))]
|
||||||
pub async fn get_logs_archive_path(handle: AppHandle) -> Result<path::PathBuf, Error2> {
|
pub async fn get_logs_archive_path(handle: AppHandle) -> Result<path::PathBuf, Error> {
|
||||||
handle
|
handle
|
||||||
.state::<controller::Controller>()
|
.state::<controller::Controller>()
|
||||||
.logs_archive()
|
.logs_archive()
|
||||||
|
Loading…
Reference in New Issue
Block a user