Skip to content

Commit f4971e9

Browse files
committed
Only retry if we're expecting an Artifact
1 parent d19f8ab commit f4971e9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

collector/src/execute/rustc.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn record(
3737
aid: database::ArtifactIdNumber,
3838
) -> anyhow::Result<()> {
3939
let checkout = Path::new("rust");
40-
let status = Command::new("git")
40+
let mut status = Command::new("git")
4141
.current_dir("rust")
4242
.arg("reset")
4343
.arg("--hard")
@@ -48,17 +48,17 @@ fn record(
4848
.status()
4949
.context("git reset --hard")?;
5050

51-
if !status.success() {
51+
if !status.success() && matches!(artifact, ArtifactId::Artifact(_)) {
5252
log::warn!("git reset --hard {} failed - trying default branch", artifact);
53-
let status = Command::new("git")
53+
status = Command::new("git")
5454
.current_dir("rust")
5555
.arg("reset")
5656
.arg("--hard")
5757
.arg("origin/HEAD")
5858
.status()
5959
.context("git reset --hard")?;
60-
assert!(status.success(), "git reset --hard successful");
6160
}
61+
assert!(status.success(), "git reset --hard successful");
6262

6363
let status = Command::new("git")
6464
.current_dir("rust")
@@ -156,7 +156,7 @@ fn record(
156156

157157
fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> {
158158
if Path::new("rust").exists() {
159-
let status = Command::new("git")
159+
let mut status = Command::new("git")
160160
.current_dir("rust")
161161
.arg("fetch")
162162
.arg("origin")
@@ -167,18 +167,17 @@ fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> {
167167
.status()
168168
.context("git fetch origin")?;
169169

170-
if !status.success() {
170+
if !status.success() && matches!(artifact, ArtifactId::Artifact(_)) {
171171
log::warn!("git fetch origin {} failed - trying default branch", artifact);
172-
let status = Command::new("git")
172+
status = Command::new("git")
173173
.current_dir("rust")
174174
.arg("fetch")
175175
.arg("origin")
176176
.arg("HEAD")
177177
.status()
178178
.context("git fetch origin HEAD")?;
179-
180-
assert!(status.success(), "git fetch successful");
181179
}
180+
assert!(status.success(), "git fetch successful");
182181

183182
} else {
184183
let status = Command::new("git")

0 commit comments

Comments
 (0)