diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8b17cbf..a965ddd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,6 +10,6 @@ repos: args: [--unsafe] - id: check-added-large-files - repo: https://github.com/teemtee/tmt.git - rev: "1.31.0" + rev: "1.75.0" hooks: - id: tmt-lint diff --git a/tests/Regression/cargo-git-submodule-scp-url/main.fmf b/tests/Regression/cargo-git-submodule-scp-url/main.fmf new file mode 100644 index 0000000..1f81f1b --- /dev/null +++ b/tests/Regression/cargo-git-submodule-scp-url/main.fmf @@ -0,0 +1,31 @@ +summary: Test cargo handles SCP-like Git submodule URLs +description: | + Downstreamed version of the upstream test git::dep_with_scp_like_submodule_url + https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs + + This test verifies that Cargo correctly handles Git submodules with SCP-like + URLs (git@github.com:foo/bar.git format) and preserves the original URL format + in error messages. + + This is a regression test for https://github.com/rust-lang/cargo/pull/16727 + + The test uses git-fetch-with-cli to enable SSH support via /usr/bin/git, which + works even on RHEL/CentOS where Cargo is built without libssh2 (rhbz#1732949). + + The test is enabled on distributions with Rust >= 1.96.0. + +tier: 1 +require+: + - git +adjust+: + - enabled: false + when: distro ~< rhel-8.10 + continue: false + + - enabled: false + when: distro ~< rhel-9.9 + continue: false + + - enabled: false + when: distro ~< rhel-10.3 + continue: false diff --git a/tests/Regression/cargo-git-submodule-scp-url/runtest.sh b/tests/Regression/cargo-git-submodule-scp-url/runtest.sh new file mode 100755 index 0000000..b55259f --- /dev/null +++ b/tests/Regression/cargo-git-submodule-scp-url/runtest.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# +# Downstreamed adaptation of the upstream Cargo test: +# git::dep_with_scp_like_submodule_url +# https://github.com/rust-lang/cargo/blob/master/tests/testsuite/git.rs +# +# REGRESSION TEST for https://github.com/rust-lang/cargo/pull/16727 +# +# This test verifies that Cargo correctly handles SCP-like URLs (git@host:path) +# in git submodules and preserves them in error messages. +# +# The test uses --config net.git-fetch-with-cli=true to delegate Git operations +# to /usr/bin/git, which has SSH support even on RHEL/CentOS where Cargo is built +# without libssh2 (rhbz#1732949). +# +# Expected behavior WITH the PR #16727 fix (Rust >= 1.96.0): +# - Cargo accepts SCP-like URLs in .gitmodules +# - Attempts to fetch the submodule via /usr/bin/git (with SSH support) +# - On failure, shows: "failed to fetch submodule `submod` from git@github.com:foo/bar.git" +# +# Expected behavior WITHOUT the fix (Rust < 1.96.0): +# - Cargo rejects SCP-like URLs as invalid +# - Shows: "invalid url `git@github.com:foo/bar.git`: relative URL without a base" +# - This test will FAIL (expected for a regression test before the fix is applied) +# +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +CRATE_NAME="foo" +CRATE_VER="0.5.0" +DEP1_NAME="dep1" +DEP2_NAME="dep2" +SCP_URL="git@github.com:foo/bar.git" + +rlJournalStart + rlPhaseStartSetup + declare tmp + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + + # Create dep2 git repository (will be used as submodule) + rlRun "mkdir $DEP2_NAME && cd $DEP2_NAME" + rlRun "git init" + rlRun "echo 'pub fn dep2() {}' > lib.rs" + rlRun "git add lib.rs" + rlRun "git -c user.name='Test' -c user.email='test@test' commit -m 'Initial commit'" + rlRun "DEP2_PATH=\$(pwd)" + rlRun "cd .." + + # Create dep1 git repository with Cargo.toml + rlRun "mkdir $DEP1_NAME && cd $DEP1_NAME" + rlRun "git init" + rlRun "mkdir src" + rlRun "echo 'pub fn dep() {}' > src/lib.rs" + cat > Cargo.toml < .gitmodules < Cargo.toml <&1 | tee output.log" 101 + + # Verify the exact error message that indicates PR #16727 is applied + # The test expects Cargo to: + # 1. Show it's updating the git submodule with the SCP URL + # 2. Fail with a specific message that includes the SCP URL + rlAssertGrep "git submodule.*$SCP_URL" output.log -Ei + rlAssertGrep "failed to fetch submodule.*submod.*from.*$SCP_URL" output.log -Ei + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -rf $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd