File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ pub struct Rustc {
2828 pub version : semver:: Version ,
2929 /// The host triple (arch-platform-OS), this comes from verbose_version.
3030 pub host : InternedString ,
31+ /// The rustc full commit hash, this comes from version_version`.
32+ pub commit_hash : String ,
3133 cache : Mutex < Cache > ,
3234}
3335
@@ -81,6 +83,18 @@ impl Rustc {
8183 verbose_version
8284 )
8385 } ) ?;
86+ let commit_hash = {
87+ let hash = extract ( "commit-hash: " ) ?;
88+ assert ! (
89+ hash. chars( ) . all( |ch| ch. is_ascii_hexdigit( ) ) ,
90+ "commit hash must be a hex string"
91+ ) ;
92+ assert ! (
93+ hash. len( ) == 40 || hash. len( ) == 64 ,
94+ "hex string must be generated from sha1 or sha256"
95+ ) ;
96+ hash. to_string ( )
97+ } ;
8498
8599 Ok ( Rustc {
86100 path,
@@ -89,6 +103,7 @@ impl Rustc {
89103 verbose_version,
90104 version,
91105 host,
106+ commit_hash,
92107 cache : Mutex :: new ( cache) ,
93108 } )
94109 }
You can’t perform that action at this time.
0 commit comments