From 7db1fef174dbf26905174d196b4f4a6fd6eb2b7b Mon Sep 17 00:00:00 2001 From: "Seo, Sinhyeok" Date: Sat, 29 Jun 2024 00:05:48 +0900 Subject: [PATCH] fix: Provide web compare URL instead of panic on GitLab compare API failure --- src/pipelines/gitlab_ci.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pipelines/gitlab_ci.rs b/src/pipelines/gitlab_ci.rs index 812cb85..38078d3 100644 --- a/src/pipelines/gitlab_ci.rs +++ b/src/pipelines/gitlab_ci.rs @@ -86,7 +86,10 @@ impl GitlabCI { if from == "v0.0.0" { notes += &self.commits(to); } else { - notes += &self.compare(from, to).unwrap_or_else(|e| panic!("{}", e)); + notes += &self.compare(from, to).unwrap_or_else(|e| { + println!("{}", e); + self.web_compare_url(from, to) + }) } } @@ -103,6 +106,17 @@ impl GitlabCI { format!(r#"Full Changelog: {}"#, commits) } + fn web_compare_url(&self, from: &str, to: &str) -> String { + format!( + r#"# What's Changed +{}/-/compare/{}...{}?from_project_id={}"#, + config::env_var("CI_PROJECT_URL"), + from, + to, + config::env_var("CI_PROJECT_ID") + ) + } + fn compare(&self, from: &str, to: &str) -> Result> { let url = format!( "{}/projects/{}/repository/compare",