@@ -1268,7 +1268,8 @@ pub mod install {
12681268 pub branch : Option < String > ,
12691269 }
12701270
1271- pub const VERUS_REPO : & str =
"https://[email protected] /asterinas/verus.git" ; 1271+ pub const VERUS_REPO_HTTPS : & str = "https://github.com/asterinas/verus.git" ;
1272+ pub const VERUS_REPO_SSH : & str =
"[email protected] :asterinas/verus.git" ; 12721273
12731274 #[ memoize]
12741275 pub fn tools_dir ( ) -> PathBuf {
@@ -1291,15 +1292,27 @@ pub mod install {
12911292 }
12921293
12931294 pub fn clone_repo ( verus_dir : & Path ) -> Result < ( ) , DynError > {
1294- info ! (
1295- "Cloning Verus repo {} to {} ..." ,
1296- VERUS_REPO ,
1297- verus_dir. display( )
1298- ) ;
1295+ info ! ( "Cloning Verus repo to {} ..." , verus_dir. display( ) ) ;
12991296
1300- Repository :: clone ( VERUS_REPO , verus_dir) . unwrap_or_else ( |e| {
1301- error ! ( "Failed to clone verus repo: {}" , e) ;
1297+ let mut builder = git2:: build:: RepoBuilder :: new ( ) ;
1298+ let mut callbacks = git2:: RemoteCallbacks :: new ( ) ;
1299+
1300+ callbacks. credentials ( |_url, username_from_url, _allowed_types| {
1301+ git2:: Cred :: ssh_key_from_agent ( username_from_url. unwrap_or ( "git" ) )
13021302 } ) ;
1303+
1304+ let mut fetch_opts = git2:: FetchOptions :: new ( ) ;
1305+ fetch_opts. remote_callbacks ( callbacks) ;
1306+ builder. fetch_options ( fetch_opts) ;
1307+
1308+ let ssh_result = builder. clone ( VERUS_REPO_SSH , verus_dir) ;
1309+ if ssh_result. is_ok ( ) {
1310+ return Ok ( ( ) ) ;
1311+ }
1312+
1313+ Repository :: clone ( VERUS_REPO_HTTPS , verus_dir)
1314+ . map_err ( |e| format ! ( "Failed to clone verus repo: {}" , e) ) ?;
1315+
13031316 Ok ( ( ) )
13041317 }
13051318
@@ -1440,17 +1453,6 @@ pub mod install {
14401453 // Download Z3
14411454 install_z3 ( ) ?;
14421455
1443- // Apply patches
1444- /*let verus_patch = tools_patch_dir().join("verus-fixes.patch");
1445- if verus_patch.exists() && !commands::is_patch_applied(&verus_dir, &verus_patch) {
1446- status!(
1447- "Applying patch {} to {} ...",
1448- verus_patch.display(),
1449- verus_dir.display()
1450- );
1451- commands::apply_patch(&verus_dir, &verus_patch);
1452- }*/
1453-
14541456 // Build Verus
14551457 build_verus ( options. release ) ?;
14561458
@@ -1481,10 +1483,19 @@ pub mod install {
14811483 // Determine target branch (default to "main")
14821484 let target_branch = branch. unwrap_or ( "main" ) ;
14831485
1484- // Find the remote and fetch the target branch
1486+ // Find the remote and check its URL to determine authentication method
14851487 let mut remote = repo. find_remote ( "origin" ) ?;
1488+ let remote_url = remote. url ( ) . unwrap_or ( "" ) ;
1489+ let is_ssh = remote_url. starts_with ( "git@" ) || remote_url. contains ( "ssh://" ) ;
1490+
14861491 let mut callbacks = git2:: RemoteCallbacks :: new ( ) ;
1487- callbacks. credentials ( |_url, username_from_url, _allowed_types| { git2:: Cred :: ssh_key_from_agent ( username_from_url. unwrap_or ( "git" ) ) } ) ;
1492+
1493+ if is_ssh {
1494+ // SSH repository - use SSH key authentication
1495+ callbacks. credentials ( |_url, username_from_url, _allowed_types| {
1496+ git2:: Cred :: ssh_key_from_agent ( username_from_url. unwrap_or ( "git" ) )
1497+ } ) ;
1498+ }
14881499 let mut fetch_opts = git2:: FetchOptions :: new ( ) ;
14891500 fetch_opts. remote_callbacks ( callbacks) ;
14901501 remote. fetch ( & [ target_branch] , Some ( & mut fetch_opts) , None ) ?;
0 commit comments