|  | 
| 1 | 1 | use crate::*; | 
| 2 | 2 | use itertools::Itertools; | 
| 3 | 3 | use std::collections::{BTreeSet, HashMap}; | 
| 4 |  | -use std::path::Path; | 
| 5 | 4 | use tracing::{Level, info, span}; | 
| 6 | 5 | 
 | 
| 7 | 6 | pub type KnownViews = HashMap<String, (git2::Oid, BTreeSet<String>)>; | 
| @@ -118,25 +117,6 @@ pub fn memorize_from_to( | 
| 118 | 117 |     Ok(((from, oid), to_ref)) | 
| 119 | 118 | } | 
| 120 | 119 | 
 | 
| 121 |  | -fn run_command(path: &Path, cmd: &[&str]) -> String { | 
| 122 |  | -    let shell = shell::Shell { | 
| 123 |  | -        cwd: path.to_owned(), | 
| 124 |  | -    }; | 
| 125 |  | - | 
| 126 |  | -    let output = ""; | 
| 127 |  | - | 
| 128 |  | -    let (stdout, stderr, _) = shell.command(cmd); | 
| 129 |  | -    let output = format!( | 
| 130 |  | -        "{}\n\n{}:\nstdout:\n{}\n\nstderr:{}\n", | 
| 131 |  | -        output, | 
| 132 |  | -        cmd.join(" "), | 
| 133 |  | -        stdout, | 
| 134 |  | -        stderr | 
| 135 |  | -    ); | 
| 136 |  | - | 
| 137 |  | -    output | 
| 138 |  | -} | 
| 139 |  | - | 
| 140 | 120 | regex_parsed!(UpstreamRef, r"refs/josh/upstream/(?P<ns>.*[.]git)/.*", [ns]); | 
| 141 | 121 | 
 | 
| 142 | 122 | regex_parsed!( | 
| @@ -321,93 +301,3 @@ pub fn get_known_filters() -> JoshResult<std::collections::BTreeMap<String, BTre | 
| 321 | 301 |         .map(|(repo, (_, filters))| (repo.clone(), filters.clone())) | 
| 322 | 302 |         .collect()) | 
| 323 | 303 | } | 
| 324 |  | - | 
| 325 |  | -pub fn run(repo_path: &std::path::Path, do_gc: bool) -> JoshResult<()> { | 
| 326 |  | -    const CRUFT_PACK_SIZE: usize = 1024 * 1024 * 64; | 
| 327 |  | - | 
| 328 |  | -    let transaction_mirror = cache::Transaction::open(&repo_path.join("mirror"), None)?; | 
| 329 |  | -    let transaction_overlay = cache::Transaction::open(&repo_path.join("overlay"), None)?; | 
| 330 |  | - | 
| 331 |  | -    transaction_overlay | 
| 332 |  | -        .repo() | 
| 333 |  | -        .odb()? | 
| 334 |  | -        .add_disk_alternate(repo_path.join("mirror").join("objects").to_str().unwrap())?; | 
| 335 |  | - | 
| 336 |  | -    info!( | 
| 337 |  | -        "{}", | 
| 338 |  | -        run_command( | 
| 339 |  | -            transaction_mirror.repo().path(), | 
| 340 |  | -            &["git", "count-objects", "-v"] | 
| 341 |  | -        ) | 
| 342 |  | -        .replace('\n', "  ") | 
| 343 |  | -    ); | 
| 344 |  | -    info!( | 
| 345 |  | -        "{}", | 
| 346 |  | -        run_command( | 
| 347 |  | -            transaction_overlay.repo().path(), | 
| 348 |  | -            &["git", "count-objects", "-v"] | 
| 349 |  | -        ) | 
| 350 |  | -        .replace('\n', "  ") | 
| 351 |  | -    ); | 
| 352 |  | -    if std::env::var("JOSH_NO_DISCOVER").is_err() { | 
| 353 |  | -        housekeeping::discover_filter_candidates(&transaction_mirror)?; | 
| 354 |  | -    } | 
| 355 |  | -    if std::env::var("JOSH_NO_REFRESH").is_err() { | 
| 356 |  | -        refresh_known_filters(&transaction_mirror, &transaction_overlay)?; | 
| 357 |  | -    } | 
| 358 |  | -    if do_gc { | 
| 359 |  | -        info!( | 
| 360 |  | -            "\n----------\n{}\n----------", | 
| 361 |  | -            run_command( | 
| 362 |  | -                transaction_mirror.repo().path(), | 
| 363 |  | -                &[ | 
| 364 |  | -                    "git", | 
| 365 |  | -                    "repack", | 
| 366 |  | -                    "-adn", | 
| 367 |  | -                    "--keep-unreachable", | 
| 368 |  | -                    "--pack-kept-objects", | 
| 369 |  | -                    "--no-write-bitmap-index", | 
| 370 |  | -                    "--threads=4" | 
| 371 |  | -                ] | 
| 372 |  | -            ) | 
| 373 |  | -        ); | 
| 374 |  | -        info!( | 
| 375 |  | -            "\n----------\n{}\n----------", | 
| 376 |  | -            run_command( | 
| 377 |  | -                transaction_mirror.repo().path(), | 
| 378 |  | -                &["git", "multi-pack-index", "write", "--bitmap"] | 
| 379 |  | -            ) | 
| 380 |  | -        ); | 
| 381 |  | -        info!( | 
| 382 |  | -            "\n----------\n{}\n----------", | 
| 383 |  | -            run_command( | 
| 384 |  | -                transaction_overlay.repo().path(), | 
| 385 |  | -                &[ | 
| 386 |  | -                    "git", | 
| 387 |  | -                    "repack", | 
| 388 |  | -                    "-dn", | 
| 389 |  | -                    "--cruft", | 
| 390 |  | -                    &format!("--max-cruft-size={}", CRUFT_PACK_SIZE), | 
| 391 |  | -                    "--no-write-bitmap-index", | 
| 392 |  | -                    "--window-memory=128m", | 
| 393 |  | -                    "--threads=4", | 
| 394 |  | -                ] | 
| 395 |  | -            ) | 
| 396 |  | -        ); | 
| 397 |  | -        info!( | 
| 398 |  | -            "\n----------\n{}\n----------", | 
| 399 |  | -            run_command( | 
| 400 |  | -                transaction_overlay.repo().path(), | 
| 401 |  | -                &["git", "multi-pack-index", "write", "--bitmap"] | 
| 402 |  | -            ) | 
| 403 |  | -        ); | 
| 404 |  | -        info!( | 
| 405 |  | -            "\n----------\n{}\n----------", | 
| 406 |  | -            run_command( | 
| 407 |  | -                transaction_mirror.repo().path(), | 
| 408 |  | -                &["git", "count-objects", "-vH"] | 
| 409 |  | -            ) | 
| 410 |  | -        ); | 
| 411 |  | -    } | 
| 412 |  | -    Ok(()) | 
| 413 |  | -} | 
0 commit comments