(is_jj: bool)
| 193 | } |
| 194 | |
| 195 | fn 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 | |
| 236 | fn print_version(s: &str) { |
| 237 | println!("cargo::rustc-env=CASCADE_BUILD_VERSION={s}"); |
no test coverage detected