File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ pub struct Rustc {
28
28
pub version : semver:: Version ,
29
29
/// The host triple (arch-platform-OS), this comes from verbose_version.
30
30
pub host : InternedString ,
31
+ /// The rustc full commit hash, this comes from `verbose_version`.
32
+ pub commit_hash : Option < String > ,
31
33
cache : Mutex < Cache > ,
32
34
}
33
35
@@ -80,6 +82,17 @@ impl Rustc {
80
82
verbose_version
81
83
)
82
84
} ) ?;
85
+ let commit_hash = extract ( "commit-hash: " ) . ok ( ) . map ( |hash| {
86
+ debug_assert ! (
87
+ hash. chars( ) . all( |ch| ch. is_ascii_hexdigit( ) ) ,
88
+ "commit hash must be a hex string"
89
+ ) ;
90
+ debug_assert ! (
91
+ hash. len( ) == 40 || hash. len( ) == 64 ,
92
+ "hex string must be generated from sha1 or sha256"
93
+ ) ;
94
+ hash. to_string ( )
95
+ } ) ;
83
96
84
97
Ok ( Rustc {
85
98
path,
@@ -88,6 +101,7 @@ impl Rustc {
88
101
verbose_version,
89
102
version,
90
103
host,
104
+ commit_hash,
91
105
cache : Mutex :: new ( cache) ,
92
106
} )
93
107
}
You can’t perform that action at this time.
0 commit comments