From ad1acfc51248488c0ab2c06ef3462fd33b2105f9 Mon Sep 17 00:00:00 2001 From: Pierce Thompson Date: Mon, 25 Mar 2024 23:32:36 -0400 Subject: [PATCH] Always go to the tree view regardless of commit or tag --- build.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index a583417..2f9f843 100644 --- a/build.rs +++ b/build.rs @@ -14,15 +14,16 @@ fn set_repo_url() { if is_git_repo() { repo_url = get_remote_url(); - if !repo_url.ends_with('/') { - repo_url.push('/'); - } if repo_url.starts_with("https://github.com/") { - if is_git_tagged() { - repo_url.push_str(&format!("releases/tag/{}", get_git_tag())); - } else { - repo_url.push_str(&format!("commit/{}", get_git_hash())); - } + // The URL might already end with a '/', but GitHub seems to handle it fine if there's two. + repo_url.push_str(&format!( + "/tree/{}", + if is_git_tagged() { + get_git_tag() + } else { + get_git_hash() + } + )); } } else { println!("Not a Git repo! Skipping repo URL metadata");