mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-28 05:23:56 +03:00
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
/*
|
|
* hurl (https://hurl.dev)
|
|
* Copyright (C) 2020 Orange
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
*/
|
|
use std::process;
|
|
|
|
// objectives
|
|
// get version
|
|
// get git commit
|
|
// get build date
|
|
// => hard-code into your binaries
|
|
fn main() {
|
|
// Make the current git hash available to the build.
|
|
if let Some(rev) = git_revision_hash() {
|
|
println!("cargo:rustc-env=HURL_BUILD_GIT_HASH={}", rev);
|
|
}
|
|
|
|
}
|
|
|
|
fn git_revision_hash() -> Option<String> {
|
|
let result = process::Command::new("git")
|
|
.args(&["rev-parse", "--short=10", "HEAD"])
|
|
.output();
|
|
result.ok().and_then(|output| {
|
|
let v = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
|
if v.is_empty() {
|
|
None
|
|
} else {
|
|
Some(v)
|
|
}
|
|
})
|
|
}
|