Skip to content

Commit 7d114ed

Browse files
committed
fallback to calling git process on auth error
also dont update on install-binaries command, kinda pointless fixes #39
1 parent 4dc8d9b commit 7d114ed

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/sdk.rs

+21-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use serde::Deserialize;
1111
use std::env;
1212
use std::fs;
1313
use std::path::{Path, PathBuf};
14+
use std::process::Command;
1415

1516
#[cfg(target_os = "macos")]
1617
use crate::launchctl;
@@ -282,13 +283,26 @@ fn fetch_repo_info(repo: &git2::Repository) -> git2::MergeAnalysis {
282283
true
283284
});
284285

285-
remote
286-
.fetch(
287-
&["main"],
288-
Some(FetchOptions::new().remote_callbacks(callbacks)),
289-
None,
290-
)
291-
.nice_unwrap("Could not fetch latest update");
286+
let res = remote.fetch(
287+
&["main"],
288+
Some(FetchOptions::new().remote_callbacks(callbacks)),
289+
None,
290+
);
291+
if res.as_ref().is_err_and(|e| {
292+
e.message()
293+
.contains("authentication required but no callback set")
294+
}) {
295+
// Setting the authentication callback is kinda jank, just call the git process lmao
296+
Command::new("git")
297+
.args(&["fetch", "origin", "main"])
298+
.current_dir(Config::sdk_path())
299+
.spawn()
300+
.nice_unwrap("Could not fetch latest update")
301+
.wait()
302+
.nice_unwrap("Could not fetch latest update");
303+
} else {
304+
res.nice_unwrap("Could not fetch latest update");
305+
}
292306

293307
// Check if can fast-forward
294308
let fetch_head = repo.find_reference("FETCH_HEAD").unwrap();
@@ -414,7 +428,6 @@ fn switch_to_tag(config: &mut Config, repo: &Repository) {
414428
}
415429

416430
fn install_binaries(config: &mut Config, platform: Option<String>) {
417-
update(config, None);
418431
let release_tag: String;
419432
let target_dir: PathBuf;
420433
if config.sdk_nightly {

0 commit comments

Comments
 (0)