@@ -37,7 +37,7 @@ fn record(
37
37
aid : database:: ArtifactIdNumber ,
38
38
) -> anyhow:: Result < ( ) > {
39
39
let checkout = Path :: new ( "rust" ) ;
40
- let status = Command :: new ( "git" )
40
+ let mut status = Command :: new ( "git" )
41
41
. current_dir ( "rust" )
42
42
. arg ( "reset" )
43
43
. arg ( "--hard" )
@@ -47,7 +47,19 @@ fn record(
47
47
} )
48
48
. status ( )
49
49
. context ( "git reset --hard" ) ?;
50
+
51
+ if !status. success ( ) && matches ! ( artifact, ArtifactId :: Artifact ( _) ) {
52
+ log:: warn!( "git reset --hard {} failed - trying default branch" , artifact) ;
53
+ status = Command :: new ( "git" )
54
+ . current_dir ( "rust" )
55
+ . arg ( "reset" )
56
+ . arg ( "--hard" )
57
+ . arg ( "origin/HEAD" )
58
+ . status ( )
59
+ . context ( "git reset --hard" ) ?;
60
+ }
50
61
assert ! ( status. success( ) , "git reset --hard successful" ) ;
62
+
51
63
let status = Command :: new ( "git" )
52
64
. current_dir ( "rust" )
53
65
. arg ( "clean" )
@@ -144,7 +156,7 @@ fn record(
144
156
145
157
fn checkout ( artifact : & ArtifactId ) -> anyhow:: Result < ( ) > {
146
158
if Path :: new ( "rust" ) . exists ( ) {
147
- let status = Command :: new ( "git" )
159
+ let mut status = Command :: new ( "git" )
148
160
. current_dir ( "rust" )
149
161
. arg ( "fetch" )
150
162
. arg ( "origin" )
@@ -154,7 +166,19 @@ fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> {
154
166
} )
155
167
. status ( )
156
168
. context ( "git fetch origin" ) ?;
169
+
170
+ if !status. success ( ) && matches ! ( artifact, ArtifactId :: Artifact ( _) ) {
171
+ log:: warn!( "git fetch origin {} failed - trying default branch" , artifact) ;
172
+ status = Command :: new ( "git" )
173
+ . current_dir ( "rust" )
174
+ . arg ( "fetch" )
175
+ . arg ( "origin" )
176
+ . arg ( "HEAD" )
177
+ . status ( )
178
+ . context ( "git fetch origin HEAD" ) ?;
179
+ }
157
180
assert ! ( status. success( ) , "git fetch successful" ) ;
181
+
158
182
} else {
159
183
let status = Command :: new ( "git" )
160
184
. arg ( "clone" )
0 commit comments