Skip to content

Commit c779c0d

Browse files
committed
Do not rely on local repo having test branches.
1 parent cc55867 commit c779c0d

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

.github/workflows/rust.yml

-10
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ jobs:
77
- uses: actions/checkout@v4
88
with:
99
fetch-depth: 0
10-
- name: Create local branches for tests
11-
run: |
12-
for branch in test-root test-module-{a,b,c}; do
13-
git branch --track "$branch" "origin/$branch"
14-
done
1510
- name: Build
1611
run: cargo +stable build --verbose
1712
- name: Run tests
@@ -24,11 +19,6 @@ jobs:
2419
- uses: actions/checkout@v4
2520
with:
2621
fetch-depth: 0
27-
- name: Create local branches for tests
28-
run: |
29-
for branch in test-root test-module-{a,b,c}; do
30-
git branch --track "$branch" "origin/$branch"
31-
done
3222
- name: Build
3323
run: cargo +nightly build --verbose
3424
- name: Run tests

git-version/tests/version.rs

+33-5
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,47 @@ fn test_in_external_clone() {
2828
let target_dir = target_dir.join("tests_target");
2929

3030
let_assert!(Ok(result) = std::process::Command::new("git")
31-
.arg("-c")
32-
.arg("protocol.file.allow=always")
3331
.arg("clone")
3432
.arg("--quiet")
35-
.arg("--recurse-submodules")
36-
.arg("-b")
37-
.arg("test-root")
3833
.arg((lib_dir).join(".."))
3934
.arg(tempdir.path())
4035
.status()
4136
);
4237
assert!(result.success(), "git clone: {result}");
4338

39+
let_assert!(Ok(result) = std::process::Command::new("git")
40+
.current_dir(&tempdir)
41+
.arg("-c")
42+
.arg("protocol.file.allow=always")
43+
.arg("fetch")
44+
.arg("--quiet")
45+
.arg("origin")
46+
.arg("+refs/remotes/origin/test-*:refs/heads/test-*")
47+
.status()
48+
);
49+
assert!(result.success(), "git fetch: {result}");
50+
51+
let_assert!(Ok(result) = std::process::Command::new("git")
52+
.current_dir(&tempdir)
53+
.arg("switch")
54+
.arg("--quiet")
55+
.arg("test-root")
56+
.status()
57+
);
58+
assert!(result.success(), "git fetch: {result}");
59+
60+
let_assert!(Ok(result) = std::process::Command::new("git")
61+
.current_dir(&tempdir)
62+
.arg("-c")
63+
.arg("protocol.file.allow=always")
64+
.arg("submodule")
65+
.arg("--quiet")
66+
.arg("update")
67+
.arg("--init")
68+
.status()
69+
);
70+
assert!(result.success(), "git fetch: {result}");
71+
4472
let_assert!(Ok(result) = std::process::Command::new("cargo")
4573
.current_dir(&tempdir)
4674
.arg("add")

0 commit comments

Comments
 (0)