Skip to content

Commit

Permalink
Implement command_to_string
Browse files Browse the repository at this point in the history
This also drops the fun_run dependency, and produces more accurate output (e.g. by not escaping command parameters unnecessarily)
  • Loading branch information
runesoerensen committed Dec 11, 2024
1 parent 155a60c commit 8a69593
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion buildpacks/dotnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ autotests = false
workspace = true

[dependencies]
fun_run = "0.2.0"
hex = "0.4"
indoc = "2"
libcnb = "0.25"
Expand Down
12 changes: 10 additions & 2 deletions buildpacks/dotnet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use buildpacks_jvm_shared::output::{
print_buildpack_name, print_section, print_subsection, print_warning, run_command,
track_timing, BuildpackOutputTextSection,
};
use fun_run::CommandWithName;
use indoc::formatdoc;
use inventory::artifact::{Arch, Os};
use inventory::{Inventory, ParseInventoryError};
Expand Down Expand Up @@ -153,7 +152,7 @@ impl Buildpack for DotnetBuildpack {

print_subsection(vec![
BuildpackOutputTextSection::regular("Running "),
BuildpackOutputTextSection::Command(publish_command.name()),
BuildpackOutputTextSection::Command(command_to_string(&publish_command)),
]);
track_timing(|| {
run_command(
Expand Down Expand Up @@ -199,6 +198,15 @@ impl Buildpack for DotnetBuildpack {
}
}

fn command_to_string(cmd: &Command) -> String {
let mut result = cmd.get_program().to_string_lossy().to_string();
for arg in cmd.get_args() {
result.push(' ');
result.push_str(&arg.to_string_lossy());
}
result
}

fn get_solution_to_publish(app_dir: &Path) -> Result<Solution, DotnetBuildpackError> {
let solution_file_paths =
detect::solution_file_paths(app_dir).expect("function to pass after detection");
Expand Down
2 changes: 1 addition & 1 deletion buildpacks/dotnet/tests/dotnet_publish_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn test_dotnet_publish_with_global_json_and_custom_verbosity_level() {
&formatdoc! {r#"
- Publish solution
- Using `Release` build configuration
- Running dotnet publish /workspace/foo.csproj --runtime {rid} "-p:PublishDir=bin/publish" --verbosity normal
- Running dotnet publish /workspace/foo.csproj --runtime {rid} -p:PublishDir=bin/publish --verbosity normal
MSBuild version 17.8.3+195e7f5a3 for .NET
Build started <PLACEHOLDER>.
1>Project "/workspace/foo.csproj" on node 1 (Restore target(s)).
Expand Down

0 comments on commit 8a69593

Please sign in to comment.