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 {
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 : String ,
31
33
cache : Mutex < Cache > ,
32
34
}
33
35
@@ -80,6 +82,18 @@ impl Rustc {
80
82
verbose_version
81
83
)
82
84
} ) ?;
85
+ let commit_hash = {
86
+ let hash = extract ( "commit-hash: " ) ?;
87
+ assert ! (
88
+ hash. chars( ) . all( |ch| ch. is_ascii_hexdigit( ) ) ,
89
+ "commit hash must be a hex string"
90
+ ) ;
91
+ assert ! (
92
+ hash. len( ) == 40 || hash. len( ) == 64 ,
93
+ "hex string must be generated from sha1 or sha256"
94
+ ) ;
95
+ hash. to_string ( )
96
+ } ;
83
97
84
98
Ok ( Rustc {
85
99
path,
@@ -88,6 +102,7 @@ impl Rustc {
88
102
verbose_version,
89
103
version,
90
104
host,
105
+ commit_hash,
91
106
cache : Mutex :: new ( cache) ,
92
107
} )
93
108
}
You can’t perform that action at this time.
0 commit comments