diff --git a/Cargo.lock b/Cargo.lock index 62df46b4d..9439cb4e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "alerter" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "axum", @@ -943,7 +943,7 @@ dependencies = [ [[package]] name = "command" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "komodo_client", "run_command", @@ -1355,7 +1355,7 @@ dependencies = [ [[package]] name = "environment_file" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "thiserror", ] @@ -1439,7 +1439,7 @@ dependencies = [ [[package]] name = "formatting" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "serror", ] @@ -1571,7 +1571,7 @@ checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "git" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "command", @@ -2192,7 +2192,7 @@ dependencies = [ [[package]] name = "komodo_cli" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "clap", @@ -2208,7 +2208,7 @@ dependencies = [ [[package]] name = "komodo_client" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "async_timing_util", @@ -2239,7 +2239,7 @@ dependencies = [ [[package]] name = "komodo_core" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "async_timing_util", @@ -2296,7 +2296,7 @@ dependencies = [ [[package]] name = "komodo_periphery" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "async_timing_util", @@ -2383,7 +2383,7 @@ dependencies = [ [[package]] name = "logger" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "komodo_client", @@ -2447,7 +2447,7 @@ dependencies = [ [[package]] name = "migrator" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "dotenvy", @@ -3102,7 +3102,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "periphery_client" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "komodo_client", @@ -4880,7 +4880,7 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "update_logger" -version = "1.15.6" +version = "1.15.7-dev" dependencies = [ "anyhow", "komodo_client", diff --git a/Cargo.toml b/Cargo.toml index cc6adbfa3..14df569ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["bin/*", "lib/*", "client/core/rs", "client/periphery/rs"] [workspace.package] -version = "1.15.6" +version = "1.15.7-dev" edition = "2021" authors = ["mbecker20 "] license = "GPL-3.0-or-later" @@ -15,7 +15,7 @@ homepage = "https://komo.do" [workspace.dependencies] # LOCAL -# komodo_client = "1.14.3" +# komodo_client = "1.15.6" komodo_client = { path = "client/core/rs" } periphery_client = { path = "client/periphery/rs" } environment_file = { path = "lib/environment_file" } diff --git a/bin/core/src/api/write/stack.rs b/bin/core/src/api/write/stack.rs index b0051464b..0e67cdeb0 100644 --- a/bin/core/src/api/write/stack.rs +++ b/bin/core/src/api/write/stack.rs @@ -205,6 +205,7 @@ impl Resolve for State { match periphery_client(&server)? .request(WriteCommitComposeContents { stack, + username: Some(user.username), file_path, contents, git_token, diff --git a/bin/core/src/api/write/sync.rs b/bin/core/src/api/write/sync.rs index 002ff25f0..3717c95dc 100644 --- a/bin/core/src/api/write/sync.rs +++ b/bin/core/src/api/write/sync.rs @@ -190,7 +190,7 @@ impl Resolve for State { } let commit_res = git::commit_file( - "Commit Resource File", + &format!("{}: Commit Resource File", user.username), &root, &resource_path.join(&file_path), ) diff --git a/bin/periphery/src/api/compose.rs b/bin/periphery/src/api/compose.rs index 3323612f6..672e7c2d9 100644 --- a/bin/periphery/src/api/compose.rs +++ b/bin/periphery/src/api/compose.rs @@ -259,6 +259,7 @@ impl Resolve for State { &self, WriteCommitComposeContents { stack, + username, file_path, contents, git_token, @@ -326,18 +327,18 @@ impl Resolve for State { .context("Run directory is not a valid path")? .join(&file_path); + let msg = if let Some(username) = username { + format!("{}: Write Compose File", username) + } else { + "Write Compose File".to_string() + }; + let GitRes { logs, hash, message, .. - } = write_commit_file( - "Write Compose File", - &root, - &file_path, - &contents, - ) - .await?; + } = write_commit_file(&msg, &root, &file_path, &contents).await?; Ok(RepoActionResponse { logs, diff --git a/client/periphery/rs/src/api/compose.rs b/client/periphery/rs/src/api/compose.rs index 4f31ec0a1..fef82c884 100644 --- a/client/periphery/rs/src/api/compose.rs +++ b/client/periphery/rs/src/api/compose.rs @@ -109,6 +109,8 @@ pub struct WriteComposeContentsToHost { pub struct WriteCommitComposeContents { /// The stack to write to. pub stack: Stack, + /// The username of user which committed the file. + pub username: Option, /// Relative to the stack folder + run directory. pub file_path: String, /// The contents to write. diff --git a/lib/git/src/commit.rs b/lib/git/src/commit.rs index 0a874c341..29954bf73 100644 --- a/lib/git/src/commit.rs +++ b/lib/git/src/commit.rs @@ -4,6 +4,7 @@ use anyhow::Context; use command::run_komodo_command; use formatting::format_serror; use komodo_client::entities::{all_logs_success, update::Log}; +use run_command::async_run_command; use tokio::fs; use crate::{get_commit_hash_log, GitRes}; @@ -58,6 +59,8 @@ pub async fn commit_file_inner( // relative to repo root file: &Path, ) { + ensure_global_git_config_set().await; + let add_log = run_komodo_command( "add files", repo_dir, @@ -105,6 +108,8 @@ pub async fn commit_file_inner( /// Add, commit, and force push. /// Repo must be cloned. pub async fn commit_all(repo_dir: &Path, message: &str) -> GitRes { + ensure_global_git_config_set().await; + let mut res = GitRes::default(); let add_log = @@ -147,3 +152,20 @@ pub async fn commit_all(repo_dir: &Path, message: &str) -> GitRes { res } + +async fn ensure_global_git_config_set() { + let res = + async_run_command("git config --global --get user.email").await; + if !res.success() { + let _ = async_run_command( + "git config --global user.email komodo@komo.do", + ) + .await; + } + let res = + async_run_command("git config --global --get user.name").await; + if !res.success() { + let _ = + async_run_command("git config --global user.name komodo").await; + } +}