@@ -4,7 +4,7 @@ use path_absolutize::Absolutize;
4
4
use crate :: config:: Config ;
5
5
use crate :: util:: logging:: ask_confirm;
6
6
use git2:: build:: { RepoBuilder , CheckoutBuilder } ;
7
- use git2:: { FetchOptions , RemoteCallbacks , Repository , SubmoduleUpdateOptions } ;
7
+ use git2:: { FetchOptions , RemoteCallbacks , Repository } ;
8
8
use reqwest:: header:: { USER_AGENT , AUTHORIZATION } ;
9
9
use semver:: { Version , Prerelease } ;
10
10
use serde:: Deserialize ;
@@ -230,13 +230,43 @@ fn install(config: &mut Config, path: PathBuf, force: bool) {
230
230
) ;
231
231
}
232
232
233
+ fetch_repo_info ( & repo) ;
234
+
233
235
switch_to_tag ( config, & repo) ;
234
236
235
237
done ! ( "Successfully installed SDK" ) ;
236
238
info ! ( "Please restart your command line to have the GEODE_SDK enviroment variable set." ) ;
237
239
info ! ( "Use `geode sdk install-binaries` to install pre-built binaries" ) ;
238
240
}
239
241
242
+ fn fetch_repo_info ( repo : & git2:: Repository ) -> git2:: MergeAnalysis {
243
+ let mut remote = repo. find_remote ( "origin" ) . unwrap ( ) ;
244
+
245
+ let mut callbacks = RemoteCallbacks :: new ( ) ;
246
+ callbacks. sideband_progress ( |x| {
247
+ print ! (
248
+ "{} {}" ,
249
+ "| Info |" . bright_cyan( ) ,
250
+ std:: str :: from_utf8( x) . unwrap( )
251
+ ) ;
252
+ true
253
+ } ) ;
254
+
255
+ remote
256
+ . fetch (
257
+ & [ "main" ] ,
258
+ Some ( FetchOptions :: new ( ) . remote_callbacks ( callbacks) ) ,
259
+ None ,
260
+ )
261
+ . nice_unwrap ( "Could not fetch latest update" ) ;
262
+
263
+ // Check if can fast-forward
264
+ let fetch_head = repo. find_reference ( "FETCH_HEAD" ) . unwrap ( ) ;
265
+ let fetch_commit = repo. reference_to_annotated_commit ( & fetch_head) . unwrap ( ) ;
266
+
267
+ repo. merge_analysis ( & [ & fetch_commit] ) . unwrap ( ) . 0
268
+ }
269
+
240
270
fn update ( config : & mut Config , branch : Option < String > ) {
241
271
// Switch branch if necessary
242
272
match branch. as_deref ( ) . unwrap_or ( if config. sdk_nightly { "nightly" } else { "stable" } ) {
@@ -264,31 +294,7 @@ fn update(config: &mut Config, branch: Option<String>) {
264
294
. nice_unwrap ( "Could not initialize local SDK repository" ) ;
265
295
266
296
// Fetch
267
- let mut remote = repo. find_remote ( "origin" ) . unwrap ( ) ;
268
-
269
- let mut callbacks = RemoteCallbacks :: new ( ) ;
270
- callbacks. sideband_progress ( |x| {
271
- print ! (
272
- "{} {}" ,
273
- "| Info |" . bright_cyan( ) ,
274
- std:: str :: from_utf8( x) . unwrap( )
275
- ) ;
276
- true
277
- } ) ;
278
-
279
- remote
280
- . fetch (
281
- & [ "main" ] ,
282
- Some ( FetchOptions :: new ( ) . remote_callbacks ( callbacks) ) ,
283
- None ,
284
- )
285
- . nice_unwrap ( "Could not fetch latest update" ) ;
286
-
287
- // Check if can fast-forward
288
- let fetch_head = repo. find_reference ( "FETCH_HEAD" ) . unwrap ( ) ;
289
- let fetch_commit = repo. reference_to_annotated_commit ( & fetch_head) . unwrap ( ) ;
290
-
291
- let merge_analysis = repo. merge_analysis ( & [ & fetch_commit] ) . unwrap ( ) . 0 ;
297
+ let merge_analysis = fetch_repo_info ( & repo) ;
292
298
293
299
if merge_analysis. is_up_to_date ( ) {
294
300
switch_to_tag ( config, & repo) ;
0 commit comments