mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
add functionality to PSVersionTable to include GitCommitID and update tests
This commit is contained in:
1 parent
e0149a10e4
commit
cfd5bded5b
4 files changed
+19
-2
No files matched your search
@@ -18,7 +18,8 @@
|
||||
"content": [
|
||||
"Modules",
|
||||
"../Modules",
|
||||
"powershell.exe"
|
||||
"powershell.exe",
|
||||
"../../.version"
|
||||
],
|
||||
|
||||
"frameworks": {
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace System.Management.Automation
|
||||
_psVersionTable["PSEdition"] = PSEditionValue;
|
||||
_psVersionTable["CLRVersion"] = Environment.Version;
|
||||
_psVersionTable["BuildVersion"] = GetBuildVersion();
|
||||
_psVersionTable["GitCommitId"] = GetCommitInfo();
|
||||
_psVersionTable["PSCompatibleVersions"] = new Version[] { _psV1Version, _psV2Version, _psV3Version, _psV4Version, _psV5Version, _psV51Version };
|
||||
_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion);
|
||||
_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion;
|
||||
@@ -81,6 +82,18 @@ namespace System.Management.Automation
|
||||
return new Version(buildVersion);
|
||||
}
|
||||
|
||||
// Get the commit id from the .version file. If the .version file doesn't exist, use the string "N/A"
|
||||
static internal string GetCommitInfo()
|
||||
{
|
||||
try {
|
||||
string assemblyPath = IO.Path.GetDirectoryName(typeof(PSVersionInfo).GetTypeInfo().Assembly.Location);
|
||||
return (IO.File.ReadAllLines(IO.Path.Combine(assemblyPath,".version"))[0]);
|
||||
}
|
||||
catch (Exception e){
|
||||
return e.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#region Private helper methods
|
||||
|
||||
// Gets the current WSMan stack version from the registry.
|
||||
|
||||
Reference in new issue
Block a user