@@ -31,10 +31,11 @@ use tee::TeeReader;
31
31
use tempdir:: TempDir ;
32
32
use xz2:: read:: XzDecoder ;
33
33
34
- mod git;
35
34
mod least_satisfying;
35
+ mod repo_access;
36
36
37
37
use crate :: least_satisfying:: { least_satisfying, Satisfies } ;
38
+ use crate :: repo_access:: { AccessViaLocalGit , RustRepositoryAccessor } ;
38
39
39
40
#[ derive( Debug , Clone , PartialEq ) ]
40
41
pub struct Commit {
@@ -54,14 +55,6 @@ const EPOCH_COMMIT: &str = "927c55d86b0be44337f37cf5b0a76fb8ba86e06c";
54
55
const NIGHTLY_SERVER : & str = "https://static.rust-lang.org/dist" ;
55
56
const CI_SERVER : & str = "https://s3-us-west-1.amazonaws.com/rust-lang-ci2" ;
56
57
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
-
65
58
#[ derive( Debug , StructOpt ) ]
66
59
#[ structopt( after_help = "EXAMPLES:
67
60
Run a fully automatic nightly bisect doing `cargo check`:
@@ -152,6 +145,9 @@ struct Opts {
152
145
) ]
153
146
by_commit : bool ,
154
147
148
+ #[ structopt( long = "access" , help = "How to access Rust git repository [github|checkout]" ) ]
149
+ access : Option < String > ,
150
+
155
151
#[ structopt( long = "install" , help = "Install the given artifact" ) ]
156
152
install : Option < Bound > ,
157
153
@@ -875,6 +871,7 @@ struct Config {
875
871
toolchains_path : PathBuf ,
876
872
target : String ,
877
873
is_commit : bool ,
874
+ repo_access : Box < dyn RustRepositoryAccessor > ,
878
875
}
879
876
880
877
impl Config {
@@ -946,12 +943,20 @@ impl Config {
946
943
}
947
944
}
948
945
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
+
949
953
Ok ( Config {
950
954
is_commit : args. by_commit || is_commit == Some ( true ) ,
951
955
args,
952
956
target,
953
957
toolchains_path,
954
958
rustup_tmp_path,
959
+ repo_access,
955
960
} )
956
961
}
957
962
}
@@ -990,7 +995,7 @@ fn run() -> Result<(), Error> {
990
995
fn install ( cfg : & Config , client : & Client , bound : & Bound ) -> Result < ( ) , Error > {
991
996
match * bound {
992
997
Bound :: Commit ( ref sha) => {
993
- let sha = git :: expand_commit ( sha) ?;
998
+ let sha = cfg . repo_access . commit ( sha) ?. sha ;
994
999
let mut t = Toolchain {
995
1000
spec : ToolchainSpec :: Ci {
996
1001
commit : sha. clone ( ) ,
@@ -1040,7 +1045,13 @@ fn bisect(cfg: &Config, client: &Client) -> Result<(), Error> {
1040
1045
previous_date. format( YYYY_MM_DD ) ,
1041
1046
) ;
1042
1047
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
+
1044
1055
print_results ( cfg, client, & ci_bisection_result) ;
1045
1056
print_final_report ( & nightly_bisection_result, & ci_bisection_result) ;
1046
1057
}
@@ -1387,12 +1398,45 @@ fn bisect_ci(cfg: &Config, client: &Client) -> Result<BisectionResult, Error> {
1387
1398
1388
1399
eprintln ! ( "starting at {}, ending at {}" , start, end) ;
1389
1400
1390
- bisect_ci_between ( cfg, client, start, end)
1401
+ bisect_ci_via ( cfg, client, & * cfg . repo_access , start, end)
1391
1402
}
1392
1403
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
+ {
1394
1439
let dl_spec = DownloadParams :: for_ci ( cfg) ;
1395
- let mut commits = get_commits ( start, end) ?;
1396
1440
let now = chrono:: Utc :: now ( ) ;
1397
1441
commits. retain ( |c| now. signed_duration_since ( c. date ) . num_days ( ) < 167 ) ;
1398
1442
0 commit comments