MCPcopy Create free account
hub / github.com/NLnetLabs/cascade / get_commit_id

Function get_commit_id

build.rs:195–234  ·  view source on GitHub ↗
(is_jj: bool)

Source from the content-addressed store, hash-verified

193}
194
195fn get_commit_id(is_jj: bool) -> String {
196 let (mut git_hash, is_dirty) = if is_jj {
197 let git_hash = run_cmd_strip(
198 "jj",
199 [
200 "log",
201 "--ignore-working-copy",
202 "-G",
203 "-T",
204 "commit_id.short(10)",
205 "-r",
206 "@-",
207 ],
208 )
209 .unwrap();
210 let is_dirty = match run_cmd_strip("jj", ["log", "-G", "-T", "empty", "-r", "@"])
211 .unwrap()
212 .as_str()
213 {
214 "true" => false,
215 "false" => true,
216 _ => unreachable!(),
217 };
218 (git_hash, is_dirty)
219 } else {
220 let git_hash = run_cmd_strip("git", ["rev-parse", "--short=10", "HEAD"]).unwrap();
221 let is_dirty = !run_cmd("git", ["diff-index", "--quiet", "HEAD"])
222 .unwrap()
223 .status
224 .success();
225 (git_hash, is_dirty)
226 };
227
228 if is_dirty {
229 git_hash.push('-');
230 git_hash.push_str("dirty");
231 }
232
233 git_hash
234}
235
236fn print_version(s: &str) {
237 println!("cargo::rustc-env=CASCADE_BUILD_VERSION={s}");

Callers 1

mainFunction · 0.70

Calls 3

run_cmd_stripFunction · 0.70
run_cmdFunction · 0.70
as_strMethod · 0.45

Tested by

no test coverage detected