Skip to content

Commit

Permalink
Fix version without git
Browse files Browse the repository at this point in the history
  • Loading branch information
quietvoid committed Aug 4, 2024
1 parent a3075cb commit e72bfee
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
use anyhow::Result;
use vergen_gitcl::{BuildBuilder, Emitter, GitclBuilder};
use vergen_gitcl::{Emitter, GitclBuilder};

fn main() -> Result<()> {
let mut emitter = Emitter::default();

let gitcl_res = GitclBuilder::default()
let gitcl = GitclBuilder::default()
.describe(true, true, Some("[0-9]*"))
.build();
.build()?;

if let Ok(gitcl) = gitcl_res {
emitter.add_instructions(&gitcl)?;
} else {
let build = BuildBuilder::default()
.build()
.expect("non-git vergen should succeed");
emitter.add_instructions(&build)?;
}
let gitcl_res = Emitter::default()
.idempotent()
.fail_on_error()
.add_instructions(&gitcl)
.and_then(|emitter| emitter.emit());

// Generate the instructions
emitter.emit()?;
if let Err(e) = gitcl_res {
eprintln!("error occured while generating instructions: {e:?}");
Emitter::default().idempotent().fail_on_error().emit()?;
}

Ok(())
}

0 comments on commit e72bfee

Please sign in to comment.