mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-10 00:01:02 +00:00
feature: use the repo path instead of name in GetLatestCommit (#282)
* Update repo path handling in commit fetching - Changed `name` to `path` for repository identification. - Updated cache update function to use the new path field. - Improved error message for non-directory repo paths. * feat: use optional name and path in GetLatestCommit * review: don't use optional for name * review: use helper * review: remove redundant to_string()
This commit is contained in:
+2
-1
@@ -4,9 +4,10 @@ dist
|
||||
.env
|
||||
.env.development
|
||||
.DS_Store
|
||||
.idea
|
||||
|
||||
/frontend/build
|
||||
/lib/ts_client/build
|
||||
|
||||
creds.toml
|
||||
.dev
|
||||
.dev
|
||||
|
||||
@@ -8,6 +8,7 @@ use komodo_client::entities::{
|
||||
network::NetworkListItem, volume::VolumeListItem,
|
||||
},
|
||||
komodo_timestamp,
|
||||
optional_string,
|
||||
server::{Server, ServerHealth, ServerState},
|
||||
stack::{ComposeProject, StackService, StackState},
|
||||
stats::SystemStats,
|
||||
@@ -264,6 +265,7 @@ pub async fn update_cache_for_server(server: &Server) {
|
||||
let (latest_hash, latest_message) = periphery
|
||||
.request(GetLatestCommit {
|
||||
name: repo.name.clone(),
|
||||
path: optional_string(&repo.config.path),
|
||||
})
|
||||
.await
|
||||
.map(|r| (r.hash, r.message))
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use std::path::PathBuf;
|
||||
use anyhow::{anyhow, Context};
|
||||
use git::GitRes;
|
||||
use komodo_client::entities::{update::Log, CloneArgs, LatestCommit};
|
||||
@@ -16,10 +17,13 @@ impl Resolve<super::Args> for GetLatestCommit {
|
||||
self,
|
||||
_: &super::Args,
|
||||
) -> serror::Result<LatestCommit> {
|
||||
let repo_path = periphery_config().repo_dir.join(self.name);
|
||||
let repo_path = match self.path {
|
||||
Some(p) => PathBuf::from(p),
|
||||
None => periphery_config().repo_dir.join(self.name)
|
||||
};
|
||||
if !repo_path.is_dir() {
|
||||
return Err(
|
||||
anyhow!("Repo path is not directory. is it cloned?").into(),
|
||||
anyhow!("Repo path {} is not directory. is it cloned?", repo_path.display()).into(),
|
||||
);
|
||||
}
|
||||
Ok(git::get_commit_hash_info(&repo_path).await?)
|
||||
|
||||
@@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[error(serror::Error)]
|
||||
pub struct GetLatestCommit {
|
||||
pub name: String,
|
||||
pub path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
|
||||
|
||||
Reference in New Issue
Block a user