From d7df009d424dd3e5ac743f6b6888323a121c84e0 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Sat, 23 Mar 2024 16:01:23 +0800 Subject: [PATCH] feat: display git branch in job result --- server/src/formatter.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/src/formatter.rs b/server/src/formatter.rs index 8e62668..b388edc 100644 --- a/server/src/formatter.rs +++ b/server/src/formatter.rs @@ -58,6 +58,7 @@ pub fn to_html_build_result( Enqueue time: {} Time elapsed: {} Git commit: {} +Git branch: {} {}Architecture: {} Package(s) to build: {} Package(s) successfully built: {} @@ -79,6 +80,10 @@ pub fn to_html_build_result( pipeline.git_sha, &pipeline.git_sha[..8] ), + format!( + "{}", + pipeline.git_branch, &pipeline.git_branch + ), if let Some(pr) = pipeline.github_pr { format!( "GitHub PR: #{}\n", @@ -118,7 +123,7 @@ pub fn to_markdown_build_result( } = job_ok; format!( - "{} Job completed on {} \\({}\\)\n\n**Job**: {}\n**Enqueue time**: {}\n**Time elapsed**: {}s\n{}**Architecture**: {}\n**Package\\(s\\) to build**: {}\n**Package\\(s\\) successfully built**: {}\n**Package\\(s\\) failed to build**: {}\n**Package\\(s\\) not built due to previous build failure**: {}\n\n{}\n", + "{} Job completed on {} \\({}\\)\n\n**Job**: {}\n**Enqueue time**: {}\n**Time elapsed**: {}s\n{}{}**Architecture**: {}\n**Package\\(s\\) to build**: {}\n**Package\\(s\\) successfully built**: {}\n**Package\\(s\\) failed to build**: {}\n**Package\\(s\\) not built due to previous build failure**: {}\n\n{}\n", if success { SUCCESS } else { FAILED }, worker_hostname, worker_arch, @@ -126,6 +131,7 @@ pub fn to_markdown_build_result( teloxide::utils::markdown::escape(&job.creation_time.to_string()), elapsed_secs, format!("**Git commit**: [{}](https://github.com/AOSC-Dev/aosc-os-abbs/commit/{})\n", &pipeline.git_sha[..8], pipeline.git_sha), + format!("**Git branch**: [{}](https://github.com/AOSC-Dev/aosc-os-abbs/tree/{})\n", &pipeline.git_branch, pipeline.git_branch), job.arch, teloxide::utils::markdown::escape(&job.packages), teloxide::utils::markdown::escape(&successful_packages.join(", ")), @@ -207,5 +213,5 @@ fn test_format_html_build_result() { let s = to_html_build_result(&pipeline, &job, &job_ok, worker_hostname, worker_arch, true); - assert_eq!(s, "✅\u{fe0f} Job completed on Yerus (amd64)\n\nJob: #1\nEnqueue time: 1970-01-01 00:01:01 UTC\nTime elapsed: 888s\nGit commit: 34acef16\nGitHub PR: #4992\nArchitecture: amd64\nPackage(s) to build: fd\nPackage(s) successfully built: fd\nPackage(s) failed to build: None\nPackage(s) not built due to previous build failure: \n\nBuild Log >>") + assert_eq!(s, "✅\u{fe0f} Job completed on Yerus (amd64)\n\nJob: #1\nEnqueue time: 1970-01-01 00:01:01 UTC\nTime elapsed: 888s\nGit commit: 34acef16\nGit branch: fd-9.0.0\nGitHub PR: #4992\nArchitecture: amd64\nPackage(s) to build: fd\nPackage(s) successfully built: fd\nPackage(s) failed to build: None\nPackage(s) not built due to previous build failure: \n\nBuild Log >>") }