-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(webserver): extract RepositoryService (#1897)
* refactor(webserver): extract RepositoryService * add unit test * update * update naming * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a3d7a75
commit 0814898
Showing
8 changed files
with
175 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::sync::Arc; | ||
|
||
use async_trait::async_trait; | ||
use juniper::GraphQLObject; | ||
use tabby_common::config::RepositoryAccess; | ||
|
||
use super::{ | ||
git_repository::GitRepositoryService, | ||
github_repository_provider::GithubRepositoryProviderService, | ||
}; | ||
|
||
#[derive(GraphQLObject, Debug)] | ||
pub struct FileEntrySearchResult { | ||
pub r#type: String, | ||
pub path: String, | ||
|
||
/// matched indices for fuzzy search query. | ||
pub indices: Vec<i32>, | ||
} | ||
|
||
impl FileEntrySearchResult { | ||
pub fn new(r#type: String, path: String, indices: Vec<u32>) -> Self { | ||
Self { | ||
r#type, | ||
path, | ||
indices: indices.into_iter().map(|i| i as i32).collect(), | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
pub trait RepositoryService: Send + Sync + RepositoryAccess { | ||
fn git(&self) -> Arc<dyn GitRepositoryService>; | ||
fn github(&self) -> Arc<dyn GithubRepositoryProviderService>; | ||
fn access(self: Arc<Self>) -> Arc<dyn RepositoryAccess>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.