@@ -107,6 +107,7 @@ static MINGW: &'static [&'static str] = &[
107
107
struct Manifest {
108
108
manifest_version : String ,
109
109
date : String ,
110
+ git_commit_hash : String ,
110
111
pkg : BTreeMap < String , Package > ,
111
112
}
112
113
@@ -205,15 +206,10 @@ impl Builder {
205
206
206
207
self . digest_and_sign ( ) ;
207
208
let manifest = self . build_manifest ( ) ;
208
- let filename = format ! ( "channel-rust-{}.toml" , self . rust_release) ;
209
- self . write_manifest ( & toml:: to_string ( & manifest) . unwrap ( ) , & filename) ;
210
-
211
- let filename = format ! ( "channel-rust-{}-date.txt" , self . rust_release) ;
212
- self . write_date_stamp ( & manifest. date , & filename) ;
209
+ self . write_channel_files ( & self . rust_release , & manifest) ;
213
210
214
211
if self . rust_release != "beta" && self . rust_release != "nightly" {
215
- self . write_manifest ( & toml:: to_string ( & manifest) . unwrap ( ) , "channel-rust-stable.toml" ) ;
216
- self . write_date_stamp ( & manifest. date , "channel-rust-stable-date.txt" ) ;
212
+ self . write_channel_files ( "stable" , & manifest) ;
217
213
}
218
214
}
219
215
@@ -230,6 +226,7 @@ impl Builder {
230
226
let mut manifest = Manifest {
231
227
manifest_version : "2" . to_string ( ) ,
232
228
date : self . date . to_string ( ) ,
229
+ git_commit_hash : self . git_commit_hash ( "rust" , "x86_64-unknown-linux-gnu" ) ,
233
230
pkg : BTreeMap :: new ( ) ,
234
231
} ;
235
232
@@ -382,14 +379,31 @@ impl Builder {
382
379
. arg ( self . input . join ( & filename) )
383
380
. arg ( format ! ( "{}/version" , filename. replace( ".tar.gz" , "" ) ) )
384
381
. arg ( "-O" ) ;
385
- let version = t ! ( cmd. output( ) ) ;
386
- if !version . status . success ( ) {
382
+ let output = t ! ( cmd. output( ) ) ;
383
+ if !output . status . success ( ) {
387
384
panic ! ( "failed to learn version:\n \n {:?}\n \n {}\n \n {}" ,
388
385
cmd,
389
- String :: from_utf8_lossy( & version. stdout) ,
390
- String :: from_utf8_lossy( & version. stderr) ) ;
386
+ String :: from_utf8_lossy( & output. stdout) ,
387
+ String :: from_utf8_lossy( & output. stderr) ) ;
388
+ }
389
+ String :: from_utf8_lossy ( & output. stdout ) . trim ( ) . to_string ( )
390
+ }
391
+
392
+ fn git_commit_hash ( & self , component : & str , target : & str ) -> String {
393
+ let mut cmd = Command :: new ( "tar" ) ;
394
+ let filename = self . filename ( component, target) ;
395
+ cmd. arg ( "xf" )
396
+ . arg ( self . input . join ( & filename) )
397
+ . arg ( format ! ( "{}/git-commit-hash" , filename. replace( ".tar.gz" , "" ) ) )
398
+ . arg ( "-O" ) ;
399
+ let output = t ! ( cmd. output( ) ) ;
400
+ if !output. status . success ( ) {
401
+ panic ! ( "failed to learn git commit hash:\n \n {:?}\n \n {}\n \n {}" ,
402
+ cmd,
403
+ String :: from_utf8_lossy( & output. stdout) ,
404
+ String :: from_utf8_lossy( & output. stderr) ) ;
391
405
}
392
- String :: from_utf8_lossy ( & version . stdout ) . trim ( ) . to_string ( )
406
+ String :: from_utf8_lossy ( & output . stdout ) . trim ( ) . to_string ( )
393
407
}
394
408
395
409
fn hash ( & self , path : & Path ) -> String {
@@ -425,16 +439,15 @@ impl Builder {
425
439
assert ! ( t!( child. wait( ) ) . success( ) ) ;
426
440
}
427
441
428
- fn write_manifest ( & self , manifest : & str , name : & str ) {
429
- let dst = self . output . join ( name) ;
430
- t ! ( t!( File :: create( & dst) ) . write_all( manifest. as_bytes( ) ) ) ;
431
- self . hash ( & dst) ;
432
- self . sign ( & dst) ;
442
+ fn write_channel_files ( & self , channel_name : & str , manifest : & Manifest ) {
443
+ self . write ( & toml:: to_string ( & manifest) . unwrap ( ) , channel_name, ".toml" ) ;
444
+ self . write ( & manifest. date , channel_name, "-date.txt" ) ;
445
+ self . write ( & manifest. git_commit_hash , channel_name, "-git-commit-hash.txt" ) ;
433
446
}
434
447
435
- fn write_date_stamp ( & self , date : & str , name : & str ) {
436
- let dst = self . output . join ( name ) ;
437
- t ! ( t!( File :: create( & dst) ) . write_all( date . as_bytes( ) ) ) ;
448
+ fn write ( & self , contents : & str , channel_name : & str , suffix : & str ) {
449
+ let dst = self . output . join ( format ! ( "channel-rust-{}{}" , channel_name , suffix ) ) ;
450
+ t ! ( t!( File :: create( & dst) ) . write_all( contents . as_bytes( ) ) ) ;
438
451
self . hash ( & dst) ;
439
452
self . sign ( & dst) ;
440
453
}
0 commit comments