* 1.15.7-dev ensure git config set

* add username to commit msg
This commit is contained in:
Maxwell Becker
2024-10-13 10:01:14 +03:00
committed by GitHub
parent 0a81d2a0d0
commit 165131bdf8
7 changed files with 49 additions and 23 deletions

26
Cargo.lock generated
View File

@@ -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",

View File

@@ -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 <becker.maxh@gmail.com>"]
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" }

View File

@@ -205,6 +205,7 @@ impl Resolve<WriteStackFileContents, User> for State {
match periphery_client(&server)?
.request(WriteCommitComposeContents {
stack,
username: Some(user.username),
file_path,
contents,
git_token,

View File

@@ -190,7 +190,7 @@ impl Resolve<WriteSyncFileContents, User> for State {
}
let commit_res = git::commit_file(
"Commit Resource File",
&format!("{}: Commit Resource File", user.username),
&root,
&resource_path.join(&file_path),
)

View File

@@ -259,6 +259,7 @@ impl Resolve<WriteCommitComposeContents> for State {
&self,
WriteCommitComposeContents {
stack,
username,
file_path,
contents,
git_token,
@@ -326,18 +327,18 @@ impl Resolve<WriteCommitComposeContents> 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,

View File

@@ -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<String>,
/// Relative to the stack folder + run directory.
pub file_path: String,
/// The contents to write.

View File

@@ -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;
}
}