Skip to content

Commit

Permalink
Merge 'git-revspecs'
Browse files Browse the repository at this point in the history
Thanks to @Byron for suggesting this and pointing the correct API
to implement this.

Closes GH-25

Signed-off-by: 35V LG84 <[email protected]>
  • Loading branch information
35VLG84 committed Dec 19, 2024
2 parents 2b936a7 + bd1a889 commit dc505d9
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 38 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ tackler-core = "0.6.0"

New features:

* ...
* Git Backend: Add support for `revspecs` with `--input.git.ref`


==== Fixes

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
Expand Down
94 changes: 93 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion suite
2 changes: 1 addition & 1 deletion tackler-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 4 additions & 9 deletions tackler-core/src/bin/git_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

Expand Down
34 changes: 10 additions & 24 deletions tackler-core/src/parser/tackler_txns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@Byron

Byron Dec 19, 2024

It should be possible to do id.object()?.peel_to_commit()? as well.

}
};

Expand Down Expand Up @@ -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"))
}
*/
}
67 changes: 67 additions & 0 deletions tests/sh/audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit dc505d9

Please sign in to comment.