diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c49b6e7..8c107cb 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -31,7 +31,7 @@ tackler-core = "0.6.0" New features: -* ... +* Git Backend: Add support for `revspecs` with `--input.git.ref` ==== Fixes @@ -39,7 +39,7 @@ New features: Fixes in this release: * Git Backend: When opening the repo, use exact location, - don't search it upwards on the directory tree + and don't search upwards on the directory tree ==== Development diff --git a/Cargo.lock b/Cargo.lock index 1691a71..ff405f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,6 +19,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -28,6 +40,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "anstream" version = "0.6.18" @@ -436,6 +454,18 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + [[package]] name = "flate2" version = "1.0.35" @@ -446,6 +476,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -499,6 +535,7 @@ dependencies = [ "gix-glob", "gix-hash", "gix-hashtable", + "gix-index", "gix-lock", "gix-object", "gix-odb", @@ -534,6 +571,15 @@ dependencies = [ "winnow", ] +[[package]] +name = "gix-bitmap" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d48b897b4bbc881aea994b4a5bbb340a04979d7be9089791304e04a9fbc66b53" +dependencies = [ + "thiserror 2.0.6", +] + [[package]] name = "gix-chunk" version = "0.4.10" @@ -696,6 +742,34 @@ dependencies = [ "parking_lot 0.12.3", ] +[[package]] +name = "gix-index" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "270645fd20556b64c8ffa1540d921b281e6994413a0ca068596f97e9367a257a" +dependencies = [ + "bitflags 2.6.0", + "bstr", + "filetime", + "fnv", + "gix-bitmap", + "gix-features", + "gix-fs", + "gix-hash", + "gix-lock", + "gix-object", + "gix-traverse", + "gix-utils", + "gix-validate", + "hashbrown 0.14.5", + "itoa", + "libc", + "memmap2", + "rustix", + "smallvec", + "thiserror 2.0.6", +] + [[package]] name = "gix-lock" version = "15.0.1" @@ -832,12 +906,15 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44488e0380847967bc3e3cacd8b22652e02ea1eb58afb60edd91847695cd2d8d" dependencies = [ + "bitflags 2.6.0", "bstr", "gix-commitgraph", "gix-date", "gix-hash", + "gix-hashtable", "gix-object", "gix-revwalk", + "gix-trace", "thiserror 2.0.6", ] @@ -943,7 +1020,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", ] [[package]] @@ -951,6 +1028,10 @@ name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", +] [[package]] name = "hashbrown" @@ -1214,6 +1295,17 @@ version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "redox_syscall 0.5.7", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" diff --git a/suite b/suite index 5a12bfe..b002ed9 160000 --- a/suite +++ b/suite @@ -1 +1 @@ -Subproject commit 5a12bfeb6a5e2b4ff07fbe470b7986bf664bf77c +Subproject commit b002ed98dc8a7d636a75b7e6c0d266215021a14b diff --git a/tackler-core/Cargo.toml b/tackler-core/Cargo.toml index 13c55c3..e06bc17 100644 --- a/tackler-core/Cargo.toml +++ b/tackler-core/Cargo.toml @@ -47,7 +47,7 @@ sha2 = "0.10.8" sha3 = "0.10.8" digest = "0.10.7" -gix = { version = "0.68.0", default-features = false, features = [ "max-performance-safe" ] } +gix = { version = "0.68.0", default-features = false, features = ["max-performance-safe", "revision"] } toml = "0.8.19" [target.'cfg(not(target_env = "msvc"))'.dependencies] diff --git a/tackler-core/src/bin/git_bench.rs b/tackler-core/src/bin/git_bench.rs index 0239978..95791e7 100644 --- a/tackler-core/src/bin/git_bench.rs +++ b/tackler-core/src/bin/git_bench.rs @@ -102,18 +102,13 @@ fn id_33d85471_a04c_49b9_b7a0_9d7f7f5762eb__loop_with_txns_1E5_10x() { all_txns_per_s += txn_per_s; } let txn_per_s_ave = all_txns_per_s / 10.0; - // yes, these are correct - let scala_txn_per_s_ref = 40000.0; - let rust_txn_per_s_ref = 25000.0; + + let txn_per_s_scala = 40000.0; eprintln!("\nOn average {txn_per_s_ave:.0} txn/s"); eprintln!( - "Reference system (laptop): {rust_txn_per_s_ref:.0} txn/s ({:+>6.0} txn/s)", - txn_per_s_ave - rust_txn_per_s_ref - ); - eprintln!( - "Reference implementation: {scala_txn_per_s_ref:.0} txn/s ({:+>6.0} txn/s)", - txn_per_s_ave - scala_txn_per_s_ref + "Reference implementation: {txn_per_s_scala:.0} txn/s ({:>+6.0} txn/s)", + txn_per_s_ave - txn_per_s_scala ); } diff --git a/tackler-core/src/parser/tackler_txns.rs b/tackler-core/src/parser/tackler_txns.rs index 633be4d..207f87b 100644 --- a/tackler-core/src/parser/tackler_txns.rs +++ b/tackler-core/src/parser/tackler_txns.rs @@ -85,15 +85,19 @@ pub fn git_to_txns( Some(Err(())) => return Err(format!("Ambiguous abbreviated commit id {id}").into()), None => return Err(format!("Unknown commit id '{id}'").into()), }; + // This is originally commit, so no need to peel it (repo.find_object(object_id)?.try_into_commit()?, None) } GitInputSelector::Reference(ref_str) => { - let git_ref = repo.find_reference(&ref_str)?; - let id = git_ref.into_fully_peeled_id()?; - ( - repo.find_object(id)?.try_into_commit()?, - Some(ref_str.clone()), - ) + let id = repo.rev_parse_single(ref_str.as_bytes())?; + let reference = if id.to_string().starts_with(ref_str.as_str()) { + // This is tackler specific logic: don't show ref if it's plain commit id + None + } else { + Some(ref_str.clone()) + }; + // Peel it so that tags are ok + (repo.find_object(id)?.peel_to_commit()?, reference) } }; @@ -166,21 +170,3 @@ pub fn git_to_txns( &settings.get_hash(), ) } - -#[cfg(test)] -mod tests { - /* - it("create git commitId by string") { - assert(TacklerTxns.gitCommitId("1234567890") === Right[String, String]("1234567890")) - } - - it("create git ref by settings") { - val settings = Settings() - assert(TacklerTxns.gitReference(settings) === Left[String, String]("master")) - } - - it("create git ref by string") { - assert(TacklerTxns.gitReference("unit-test-ref") === Left[String, String]("unit-test-ref")) - } - */ -} diff --git a/tests/sh/audit.sh b/tests/sh/audit.sh index 07893e4..7234d7c 100755 --- a/tests/sh/audit.sh +++ b/tests/sh/audit.sh @@ -280,3 +280,70 @@ cmp_result $module $test_name txt reg cmp_result $module $test_name txn equity echo ": ok" +# +# audit-1E2-09 +# +# test: 82fe2414-9e20-45da-8f7f-6f21ae8c71f2 +rm -f $OUTPUT_DIR/* +test_name=audit-1E2-09 +echo "test: $module/$test_name: " + +$TACKLER_SH \ + --output.dir $OUTPUT_DIR \ + --output.prefix $test_name \ + --config $SUITE_PATH/audit/audit.toml \ + --reports balance \ + --accounts "^a:.*" \ + --input.git.repository $SUITE_PATH/audit/audit-repo.git \ + --input.git.dir "txns" \ + --input.git.ref "txns-1E2^^" + +echo -n "check:" +cmp_result $module $test_name txt bal +echo ": ok" + +# +# audit-1E2-10 +# +# test: 248707bc-7c58-4bab-a4a6-4cc1471fd936 +rm -f $OUTPUT_DIR/* +test_name=audit-1E2-10 +echo "test: $module/$test_name: " + +$TACKLER_SH \ + --output.dir $OUTPUT_DIR \ + --output.prefix $test_name \ + --config $SUITE_PATH/audit/audit.toml \ + --reports balance \ + --accounts "^a:.*" \ + --input.git.repository $SUITE_PATH/audit/audit-repo.git \ + --input.git.dir "txns" \ + --input.git.ref "2da8c6a30fed6e65c06070d6c12e7dcaff84b599" + +echo -n "check:" +cmp_result $module $test_name txt bal +echo ": ok" + +# +# audit-1E2-11, use abbreviated commit id, this is same +# (with the same reference) as audit-1E2-10 +# +# test: 0ae6dfb6-0975-49bc-8744-f7a4143a6ead +rm -f $OUTPUT_DIR/* +test_name=audit-1E2-10 +echo "test: $module/$test_name: " + +$TACKLER_SH \ + --output.dir $OUTPUT_DIR \ + --output.prefix $test_name \ + --config $SUITE_PATH/audit/audit.toml \ + --reports balance \ + --accounts "^a:.*" \ + --input.git.repository $SUITE_PATH/audit/audit-repo.git \ + --input.git.dir "txns" \ + --input.git.ref "2da8c6a3" + +echo -n "check:" +cmp_result $module $test_name txt bal +echo ": ok" +