-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace
vergen
by directly running git
For some reason, `vergen` was unable to find the git binary when building inside Ansible. Running git directly fixes the problem... and we also have one dependency less! 🎉
- Loading branch information
1 parent
d38c9f4
commit 7582704
Showing
4 changed files
with
20 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
use std::process::Command; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// In some cases if new migrations are added without accompanying Rust src changes | ||
// `cargo build` isn't smart enough to detect the need for recompilation to pick up | ||
// the new embedded migrations. This build script is the recommended workaround. | ||
// See <https://docs.rs/sqlx/latest/sqlx/macro.migrate.html#triggering-recompilation-on-migration-changes> | ||
println!("cargo:rerun-if-changed=migrations"); | ||
|
||
// Expose git-related information through environment variables at compile-time | ||
vergen::EmitBuilder::builder().all_git().emit()?; | ||
// Trigger recompilation if the repository's head changed, to make sure the commit information | ||
// embedded in the binary is up-to-date | ||
println!("cargo:rerun-if-changed=.git/HEAD"); | ||
|
||
// Expose git head information through environment variables at compile-time, so it can be | ||
// embedded in the binary through the `env!` macro | ||
let output = Command::new("git").args(["rev-parse", "HEAD"]).output()?; | ||
let git_sha = String::from_utf8(output.stdout)?; | ||
println!("cargo:rustc-env=GIT_HEAD_SHA={}", git_sha); | ||
|
||
let output = Command::new("git") | ||
.args(["show-branch", "--no-name", "HEAD"]) | ||
.output()?; | ||
let git_commit_message = String::from_utf8(output.stdout)?; | ||
println!("cargo:rustc-env=GIT_HEAD_COMMIT_MESSAGE={git_commit_message}"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters