Commit 50730574 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

version-helper: Check first for a git repository in the manifest dir and only then one directory up

This allows using the crate also in git repositories that contain a
single GStreamer plugin and not only in Cargo workspaces.
parent 7e93c20b
......@@ -8,13 +8,17 @@ pub fn get_info() {
let crate_dir = path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut repo_dir = crate_dir.clone();
repo_dir.pop();
// First check for a git repository in the manifest directory and if there
// is none try one directory up in case we're in a Cargo workspace
let repo = Repository::open(&repo_dir).or_else(move |_| {
repo_dir.pop();
Repository::open(&repo_dir)
});
let mut release_file = crate_dir.clone();
release_file.push("release.txt");
let repo = Repository::open(&repo_dir);
// If there is a git repository, extract the version information from there.
// Otherwise use a 'release.txt' file as fallback, or report the current
// date and an unknown revision.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment