@@ -31,10 +31,11 @@ use tee::TeeReader;
3131use tempdir:: TempDir ;
3232use xz2:: read:: XzDecoder ;
3333
34- mod git;
3534mod least_satisfying;
35+ mod repo_access;
3636
3737use crate :: least_satisfying:: { least_satisfying, Satisfies } ;
38+ use crate :: repo_access:: { AccessViaLocalGit , RustRepositoryAccessor } ;
3839
3940#[ derive( Debug , Clone , PartialEq ) ]
4041pub struct Commit {
@@ -54,14 +55,6 @@ const EPOCH_COMMIT: &str = "927c55d86b0be44337f37cf5b0a76fb8ba86e06c";
5455const NIGHTLY_SERVER : & str = "https://static.rust-lang.org/dist" ;
5556const CI_SERVER : & str = "https://s3-us-west-1.amazonaws.com/rust-lang-ci2" ;
5657
57- fn get_commits ( start : & str , end : & str ) -> Result < Vec < Commit > , Error > {
58- eprintln ! ( "fetching commits from {} to {}" , start, end) ;
59- let commits = git:: get_commits_between ( start, end) ?;
60- assert_eq ! ( commits. first( ) . expect( "at least one commit" ) . sha, git:: expand_commit( start) ?) ;
61-
62- Ok ( commits)
63- }
64-
6558#[ derive( Debug , StructOpt ) ]
6659#[ structopt( after_help = "EXAMPLES:
6760 Run a fully automatic nightly bisect doing `cargo check`:
@@ -152,6 +145,9 @@ struct Opts {
152145 ) ]
153146 by_commit : bool ,
154147
148+ #[ structopt( long = "access" , help = "How to access Rust git repository [github|checkout]" ) ]
149+ access : Option < String > ,
150+
155151 #[ structopt( long = "install" , help = "Install the given artifact" ) ]
156152 install : Option < Bound > ,
157153
@@ -875,6 +871,7 @@ struct Config {
875871 toolchains_path : PathBuf ,
876872 target : String ,
877873 is_commit : bool ,
874+ repo_access : Box < dyn RustRepositoryAccessor > ,
878875}
879876
880877impl Config {
@@ -946,12 +943,20 @@ impl Config {
946943 }
947944 }
948945
946+ let repo_access: Box < dyn RustRepositoryAccessor > ;
947+ repo_access = match args. access . as_ref ( ) . map ( |x|x. as_str ( ) ) {
948+ None | Some ( "checkout" ) => Box :: new ( AccessViaLocalGit ) ,
949+ Some ( "github" ) => unimplemented ! ( ) ,
950+ Some ( other) => bail ! ( "unknown access argument: {}" , other) ,
951+ } ;
952+
949953 Ok ( Config {
950954 is_commit : args. by_commit || is_commit == Some ( true ) ,
951955 args,
952956 target,
953957 toolchains_path,
954958 rustup_tmp_path,
959+ repo_access,
955960 } )
956961 }
957962}
@@ -990,7 +995,7 @@ fn run() -> Result<(), Error> {
990995fn install ( cfg : & Config , client : & Client , bound : & Bound ) -> Result < ( ) , Error > {
991996 match * bound {
992997 Bound :: Commit ( ref sha) => {
993- let sha = git :: expand_commit ( sha) ?;
998+ let sha = cfg . repo_access . commit ( sha) ?. sha ;
994999 let mut t = Toolchain {
9951000 spec : ToolchainSpec :: Ci {
9961001 commit : sha. clone ( ) ,
@@ -1040,7 +1045,13 @@ fn bisect(cfg: &Config, client: &Client) -> Result<(), Error> {
10401045 previous_date. format( YYYY_MM_DD ) ,
10411046 ) ;
10421047
1043- let ci_bisection_result = bisect_ci_between ( cfg, client, & working_commit, & bad_commit) ?;
1048+ let ci_bisection_result = bisect_ci_via (
1049+ cfg,
1050+ client,
1051+ & * cfg. repo_access ,
1052+ & working_commit,
1053+ & bad_commit) ?;
1054+
10441055 print_results ( cfg, client, & ci_bisection_result) ;
10451056 print_final_report ( & nightly_bisection_result, & ci_bisection_result) ;
10461057 }
@@ -1387,12 +1398,45 @@ fn bisect_ci(cfg: &Config, client: &Client) -> Result<BisectionResult, Error> {
13871398
13881399 eprintln ! ( "starting at {}, ending at {}" , start, end) ;
13891400
1390- bisect_ci_between ( cfg, client, start, end)
1401+ bisect_ci_via ( cfg, client, & * cfg . repo_access , start, end)
13911402}
13921403
1393- fn bisect_ci_between ( cfg : & Config , client : & Client , start : & str , end : & str ) -> Result < BisectionResult , Error > {
1404+ fn bisect_ci_via (
1405+ cfg : & Config ,
1406+ client : & Client ,
1407+ access : & dyn RustRepositoryAccessor ,
1408+ start_sha : & str ,
1409+ end_sha : & str )
1410+ -> Result < BisectionResult , Error >
1411+ {
1412+ let commits = access. commits ( start_sha, end_sha) ?;
1413+
1414+ assert_eq ! ( commits. last( ) . expect( "at least one commit" ) . sha, end_sha) ;
1415+
1416+ commits. iter ( ) . zip ( commits. iter ( ) . skip ( 1 ) ) . all ( |( a, b) | {
1417+ let sorted_by_date = a. date <= b. date ;
1418+ assert ! ( sorted_by_date, "commits must chronologically ordered,\
1419+ but {:?} comes after {:?}", a, b) ;
1420+ sorted_by_date
1421+ } ) ;
1422+
1423+ for ( j, commit) in commits. iter ( ) . enumerate ( ) {
1424+ eprintln ! ( " commit[{}] {}: {}" , j, commit. date. date( ) ,
1425+ commit. summary. split( "\n " ) . next( ) . unwrap( ) )
1426+ }
1427+
1428+ bisect_ci_in_commits ( cfg, client, & start_sha, & end_sha, commits)
1429+ }
1430+
1431+ fn bisect_ci_in_commits (
1432+ cfg : & Config ,
1433+ client : & Client ,
1434+ start : & str ,
1435+ end : & str ,
1436+ mut commits : Vec < Commit > )
1437+ -> Result < BisectionResult , Error >
1438+ {
13941439 let dl_spec = DownloadParams :: for_ci ( cfg) ;
1395- let mut commits = get_commits ( start, end) ?;
13961440 let now = chrono:: Utc :: now ( ) ;
13971441 commits. retain ( |c| now. signed_duration_since ( c. date ) . num_days ( ) < 167 ) ;
13981442
0 commit comments