mirror of
https://github.com/moghtech/komodo.git
synced 2026-08-24 16:00:18 +00:00
118ae9b92c
* update easy deps * update otel deps * implement template in types + update resource meta * ts types * dev-2 * dev-3 default template query is include * Toggle resource is template in resource header * dev-4 support CopyServer * gen ts * style template selector in New Resource menu * fix new menu show 0 * add template market in omni search bar * fix some dynamic import behavior * template badge on dashboard * dev-5 * standardize interpolation methods with nice api * core use new interpolation methods * refactor git usage * dev-6 refactor interpolation / git methods * fix pull stack passed replacers * new types * remove redundant interpolation for build secret args * clean up periphery docker client * dev-7 include ports in container summary, see if they actually come through * show container ports in container table * refresh processes without tasks (more efficient) * dev-8 keep container stats cache, include with ContainerListItem * gen types * display more container ports * dev-9 fix repo clone when repo doesn't exist initially * Add ports display to more spots * fix function name * add Periphery full container stats api, may be used later * server container stats list * dev-10 * 1.18.4 release * Use reset instead of invalidate to fix GetUser spam on token expiry (#618) --------- Co-authored-by: Jacky Fong <hello@huzky.dev>
62 lines
1.4 KiB
Rust
62 lines
1.4 KiB
Rust
use std::path::Path;
|
|
|
|
use command::run_komodo_command;
|
|
use formatting::format_serror;
|
|
use komodo_client::entities::{
|
|
RepoExecutionArgs, all_logs_success, update::Log,
|
|
};
|
|
|
|
pub async fn init_folder_as_repo(
|
|
folder_path: &Path,
|
|
args: &RepoExecutionArgs,
|
|
access_token: Option<&str>,
|
|
logs: &mut Vec<Log>,
|
|
) {
|
|
// let folder_path = args.path(repo_dir);
|
|
// Initialize the folder as a git repo
|
|
let init_repo =
|
|
run_komodo_command("Git Init", folder_path, "git init").await;
|
|
logs.push(init_repo);
|
|
if !all_logs_success(logs) {
|
|
return;
|
|
}
|
|
|
|
let repo_url = match args.remote_url(access_token) {
|
|
Ok(url) => url,
|
|
Err(e) => {
|
|
logs
|
|
.push(Log::error("Add git remote", format_serror(&e.into())));
|
|
return;
|
|
}
|
|
};
|
|
|
|
// Set remote url
|
|
let mut set_remote = run_komodo_command(
|
|
"Add git remote",
|
|
folder_path,
|
|
format!("git remote add origin {repo_url}"),
|
|
)
|
|
.await;
|
|
// Sanitize the output
|
|
if let Some(token) = &access_token {
|
|
set_remote.command = set_remote.command.replace(token, "<TOKEN>");
|
|
set_remote.stdout = set_remote.stdout.replace(token, "<TOKEN>");
|
|
set_remote.stderr = set_remote.stderr.replace(token, "<TOKEN>");
|
|
}
|
|
if !set_remote.success {
|
|
logs.push(set_remote);
|
|
return;
|
|
}
|
|
|
|
// Set branch.
|
|
let init_repo = run_komodo_command(
|
|
"Set Branch",
|
|
folder_path,
|
|
format!("git switch -c {}", args.branch),
|
|
)
|
|
.await;
|
|
if !init_repo.success {
|
|
logs.push(init_repo);
|
|
}
|
|
}
|