fix version when compiled at a specific commit

When a specific commit is checked out from the main branch, the vaultwarden
version is reported as `vaultwarden x.y.z-githash (HEAD)`.
This is a problem, because the admin interface reports this as a version from
a branch called HEAD, while in reality the commit was from the main branch.
This commit is contained in:
Helmut K. C. Tessarek 2023-07-04 18:08:52 -04:00
parent a6cfdddfd8
commit 2b32b6f78c
No known key found for this signature in database
GPG key ID: BE0985349D44DD00

View file

@ -72,7 +72,7 @@ fn version_from_git_info() -> Result<String, std::io::Error> {
// Combined version // Combined version
if let Some(exact) = exact_tag { if let Some(exact) = exact_tag {
Ok(exact) Ok(exact)
} else if &branch != "main" && &branch != "master" { } else if &branch != "main" && &branch != "master" && &branch != "HEAD" {
Ok(format!("{last_tag}-{rev_short} ({branch})")) Ok(format!("{last_tag}-{rev_short} ({branch})"))
} else { } else {
Ok(format!("{last_tag}-{rev_short}")) Ok(format!("{last_tag}-{rev_short}"))