From 13a7d1f43f17bc592d8b77271fcdadbd21b93227 Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Mon, 11 Apr 2022 08:03:47 -0300 Subject: [PATCH 1/3] run update_crates only after patching --- check_dependent_project.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index d6feb3a..12f1c13 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -314,6 +314,10 @@ process_pr_description() { } update_crates() { + if [ $? -eq 0 ]; then + return + fi + local args=() for crate in "$@"; do @@ -329,11 +333,9 @@ patch_and_check_dependent() { pushd "$dependent_repo_dir" >/dev/null - # Update the crates to the latest version. This is for example needed if there - # was a PR to Substrate which only required a Polkadot companion and Cumulus - # wasn't yet updated to use the latest commit of Polkadot. - update_crates $update_crates_on_default_branch - + # The crates are matched *BEFORE* patching so that we can detect lingering + # dependencies which would be removed in this pull request but might not + # have been pruned properly from the companion match_dependent_crates "$dependent" for comp in "${dependent_companions[@]}"; do @@ -356,6 +358,13 @@ patch_and_check_dependent() { --crates-to-patch "$this_repo_dir" \ --path "Cargo.toml" + # Update the crates to the latest version. This is for example needed if there + # was a PR to Substrate which only required a Polkadot companion and Cumulus + # wasn't yet updated to use the latest commit of Polkadot. + # This should be done only *AFTER* patching so that "cargo update" will be + # able to find new crates introduced in the current pull request. + update_crates $update_crates_on_default_branch + eval "${COMPANION_CHECK_COMMAND:-cargo check --all-targets --workspace}" popd >/dev/null From a869b2e0dcbf8ca0654acf82f36e77f5da0f111f Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Mon, 11 Apr 2022 08:24:09 -0300 Subject: [PATCH 2/3] match dependents after patching --- check_dependent_project.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index 12f1c13..8ffc84b 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -333,11 +333,6 @@ patch_and_check_dependent() { pushd "$dependent_repo_dir" >/dev/null - # The crates are matched *BEFORE* patching so that we can detect lingering - # dependencies which would be removed in this pull request but might not - # have been pruned properly from the companion - match_dependent_crates "$dependent" - for comp in "${dependent_companions[@]}"; do echo "Patching $this_repo into the $comp companion, which is a dependency of $dependent_repo, assuming $comp also depends on $this_repo. Reasoning: if a companion was referenced in this PR or a companion of this PR, then it probably has a dependency on this PR, since PR descriptions are processed starting from the dependencies." diener patch \ @@ -358,6 +353,11 @@ patch_and_check_dependent() { --crates-to-patch "$this_repo_dir" \ --path "Cargo.toml" + # The crates are matched *AFTER* patching so that we verify that dependencies + # which are removed in this pull request have been pruned properly from the + # companion + match_dependent_crates "$dependent" + # Update the crates to the latest version. This is for example needed if there # was a PR to Substrate which only required a Polkadot companion and Cumulus # wasn't yet updated to use the latest commit of Polkadot. From 6f9d6e066a6144b2536133ec353be679dca87e7c Mon Sep 17 00:00:00 2001 From: joao-paulo-parity Date: Mon, 11 Apr 2022 08:39:06 -0300 Subject: [PATCH 3/3] fix operator --- check_dependent_project.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_dependent_project.sh b/check_dependent_project.sh index 8ffc84b..3475232 100755 --- a/check_dependent_project.sh +++ b/check_dependent_project.sh @@ -314,7 +314,7 @@ process_pr_description() { } update_crates() { - if [ $? -eq 0 ]; then + if [ $# -eq 0 ]; then return fi