mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 12:23:34 -05:00
lint: Move commit range printing to test_runner
Having a single test_runner for all logic improves the consistency and UX.
This commit is contained in:
parent
fa673cf344
commit
fa99728b0c
2 changed files with 17 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Copyright (c) 2018-2022 The Bitcoin Core developers
|
# Copyright (c) 2018-present The Bitcoin Core developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -9,22 +9,13 @@ export LC_ALL=C
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
if [ -n "$CIRRUS_PR" ]; then
|
if [ -n "$CIRRUS_PR" ]; then
|
||||||
COMMIT_RANGE="HEAD~..HEAD"
|
export COMMIT_RANGE="HEAD~..HEAD"
|
||||||
if [ "$(git rev-list -1 HEAD)" != "$(git rev-list -1 --merges HEAD)" ]; then
|
if [ "$(git rev-list -1 HEAD)" != "$(git rev-list -1 --merges HEAD)" ]; then
|
||||||
echo "Error: The top commit must be a merge commit, usually the remote 'pull/${PR_NUMBER}/merge' branch."
|
echo "Error: The top commit must be a merge commit, usually the remote 'pull/${PR_NUMBER}/merge' branch."
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# Otherwise, assume that a merge commit exists. This merge commit is assumed
|
|
||||||
# to be the base, after which linting will be done. If the merge commit is
|
|
||||||
# HEAD, the range will be empty.
|
|
||||||
COMMIT_RANGE="$( git rev-list --max-count=1 --merges HEAD )..HEAD"
|
|
||||||
fi
|
fi
|
||||||
export COMMIT_RANGE
|
|
||||||
|
|
||||||
echo
|
|
||||||
git log --no-merges --oneline "$COMMIT_RANGE"
|
|
||||||
echo
|
|
||||||
RUST_BACKTRACE=1 "${LINT_RUNNER_PATH}/test_runner"
|
RUST_BACKTRACE=1 "${LINT_RUNNER_PATH}/test_runner"
|
||||||
|
|
||||||
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
|
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
|
||||||
|
|
|
@ -180,7 +180,17 @@ fn get_git_root() -> PathBuf {
|
||||||
|
|
||||||
/// Return the commit range, or panic
|
/// Return the commit range, or panic
|
||||||
fn commit_range() -> String {
|
fn commit_range() -> String {
|
||||||
env::var("COMMIT_RANGE").unwrap()
|
// Use the env var, if set. E.g. COMMIT_RANGE='HEAD~n..HEAD' for the last 'n' commits.
|
||||||
|
env::var("COMMIT_RANGE").unwrap_or_else(|_| {
|
||||||
|
// Otherwise, assume that a merge commit exists. This merge commit is assumed
|
||||||
|
// to be the base, after which linting will be done. If the merge commit is
|
||||||
|
// HEAD, the range will be empty.
|
||||||
|
format!(
|
||||||
|
"{}..HEAD",
|
||||||
|
check_output(git().args(["rev-list", "--max-count=1", "--merges", "HEAD"]))
|
||||||
|
.expect("check_output failed")
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return all subtree paths
|
/// Return all subtree paths
|
||||||
|
@ -673,6 +683,10 @@ fn main() -> ExitCode {
|
||||||
};
|
};
|
||||||
|
|
||||||
let git_root = get_git_root();
|
let git_root = get_git_root();
|
||||||
|
let commit_range = commit_range();
|
||||||
|
let commit_log = check_output(git().args(["log", "--no-merges", "--oneline", &commit_range]))
|
||||||
|
.expect("check_output failed");
|
||||||
|
println!("Checking commit range ({commit_range}):\n{commit_log}\n");
|
||||||
|
|
||||||
let mut test_failed = false;
|
let mut test_failed = false;
|
||||||
for linter in linters_to_run {
|
for linter in linters_to_run {
|
||||||
|
|
Loading…
Add table
Reference in a new issue