Skip to content

Commit

Permalink
fix: Provide web compare URL instead of panic on GitLab compare API f…
Browse files Browse the repository at this point in the history
…ailure
  • Loading branch information
Sinhyeok committed Jun 28, 2024
1 parent 2a5c62f commit 7db1fef
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pipelines/gitlab_ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}

Expand All @@ -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<String, Box<dyn Error>> {
let url = format!(
"{}/projects/{}/repository/compare",
Expand Down

0 comments on commit 7db1fef

Please sign in to comment.