From f9b7660d310bef54308655f4383f4fa255b5dc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= Date: Tue, 22 Oct 2024 12:10:34 +0300 Subject: [PATCH] chore: add `--author=` flag to `git-commit` cmd in `new` flow --- .github/workflows/test.yml | 15 +++++---------- cargo-near/src/commands/new/mod.rs | 12 ++---------- .../tests/cargo_near_new_integration.rs | 7 ++++++- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f973622..61f22d95 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,13 +33,9 @@ jobs: - name: Install packages (Linux) if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev git + run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev - - name: Carg | - git --version - git config user.name "GitHub Actions Bot" - git config user.email "<>" - o check + - name: Cargo check run: | cargo check -p cargo-near cargo check -p cargo-near-build --all-features @@ -69,13 +65,12 @@ jobs: - name: Install packages (Linux) if: runner.os == 'Linux' - run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev git + run: sudo apt-get update && sudo apt-get install --assume-yes libudev-dev - name: Run tests run: | - git --version - git config user.name "GitHub Actions Bot" - git config user.email "<>" + git config --global user.email "nearprotocol-ci@near.org" + git config --global user.name "nearprotocol-ci" cargo test --workspace lint: diff --git a/cargo-near/src/commands/new/mod.rs b/cargo-near/src/commands/new/mod.rs index c0c06fb4..631dc257 100644 --- a/cargo-near/src/commands/new/mod.rs +++ b/cargo-near/src/commands/new/mod.rs @@ -96,28 +96,20 @@ impl NewContext { )); } - // let status = std::process::Command::new("git") let child = std::process::Command::new("git") .arg("commit") .arg("-m") .arg("init") + .arg("--author=nearprotocol-ci ") .current_dir(project_dir) .stdout(Stdio::piped()) .stderr(Stdio::piped()) - // .stdout(Stdio::null()) - // .stderr(Stdio::null()) - // .status()?; .spawn()?; - // if !status.success() { - // return Err(color_eyre::eyre::eyre!( - // "Failed to execute process: `git commit -m init`" - // )); - // } let output = child.wait_with_output()?; if !output.status.success() { println!("{}", String::from_utf8_lossy(&output.stderr)); return Err(color_eyre::eyre::eyre!( - "Failed to execute process: `cargo update`" + "Failed to execute process: `git commit -m init --author='nearprotocol-ci '`" )); } diff --git a/integration-tests/tests/cargo_near_new_integration.rs b/integration-tests/tests/cargo_near_new_integration.rs index 88181077..1a800b4b 100644 --- a/integration-tests/tests/cargo_near_new_integration.rs +++ b/integration-tests/tests/cargo_near_new_integration.rs @@ -42,6 +42,12 @@ fn test_docker_build() -> cargo_near::CliResult { Ok(()) } +#[test] +fn test_new_command() -> cargo_near::CliResult { + let _generated_dir = run_cargo_near_new()?; + Ok(()) +} + #[cfg(target_os = "linux")] fn get_workspaces_rs_version(manifest_path: &camino::Utf8PathBuf) -> color_eyre::Result { use color_eyre::eyre::OptionExt; @@ -69,7 +75,6 @@ fn get_workspaces_rs_version(manifest_path: &camino::Utf8PathBuf) -> color_eyre: Ok(result) } -#[cfg(target_os = "linux")] fn run_cargo_near_new() -> color_eyre::Result { let out_path = { let tmp_dir = tempfile::Builder::new()