Skip to content

Commit dc712fe

Browse files
committed
[Dogfood] Show changes in prompt
1 parent 4052072 commit dc712fe

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
lines changed

eng/dogfood.ps1

+15-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function Print-Usage() {
2626
Write-Host "if it is set, will be used."
2727
}
2828

29-
function Global:prompt {"(dogfood) PS $PWD> "}
3029

3130
if ($help -or (($command -ne $null) -and ($command.Contains("/help") -or $command.Contains("/?")))) {
3231
Print-Usage
@@ -38,10 +37,10 @@ try {
3837
. $PSScriptroot\restore-toolset.ps1
3938

4039
$env:SDK_REPO_ROOT = $RepoRoot
41-
4240
$TestDotnetRoot = Join-Path $ArtifactsDir "bin\redist\$configuration\dotnet"
43-
4441
$testDotnetVersion = (Get-Childitem -Directory "$TestDotnetRoot\sdk")[-1].Name
42+
43+
$env:TestDotnetSdkHash = Get-Content -Path (Join-Path $TestDotnetRoot "sdk\$testDotnetVersion\.version") -TotalCount 1
4544
$env:DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR = Join-Path $TestDotnetRoot "sdk\$testDotnetVersion\Sdks"
4645
$env:MicrosoftNETBuildExtensionsTargets = Join-Path $ArtifactsDir "bin\$configuration\Sdks\Microsoft.NET.Build.Extensions\msbuildExtensions\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.targets"
4746

@@ -52,13 +51,25 @@ try {
5251
# Locally built SDK package version is Major.Minor.0-dev, which won't be available.
5352
$env:BuildWithNetFrameworkHostedCompiler = $false
5453

54+
# Prompt
55+
function global:prompt {
56+
# Run command agains $env:SDK_REPO_ROOT to see if there are any changes
57+
$testDotnetSdkCurrentHash = git -C $env:SDK_REPO_ROOT rev-parse HEAD
58+
$hasGitChanges = (git status -C $env:SDK_REPO_ROOT --porcelain) -ne "" -or $testDotnetSdkCurrentHash -ne $env:TestDotnetSdkHash
59+
if ($hasGitChanges) {
60+
"$([char]0x1b)[0;35m(dotnet dogfood *)$([char]0x1b)[0m $PWD > "
61+
} else {
62+
"$([char]0x1b)[0;35m(dotnet dogfood)$([char]0x1b)[0m $PWD > "
63+
}
64+
}
65+
5566
if ($command -eq $null -and $env:DOTNET_SDK_DOGFOOD_SHELL -ne $null) {
5667
$command = , $env:DOTNET_SDK_DOGFOOD_SHELL
5768
}
5869

5970
if ($command -ne $null) {
6071
$Host.UI.RawUI.WindowTitle = "SDK Test ($RepoRoot) ($configuration)"
61-
& $command[0] $command[1..($command.Length-1)]
72+
& $command[0] $command[1..($command.Length-1)]
6273
}
6374
}
6475
catch {

eng/dogfood.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,19 @@ export SDK_REPO_ROOT="$repo_root"
2121
testDotnetRoot="$artifacts_dir/bin/redist/$configuration/dotnet"
2222
testDotnetVersion=$(ls $testDotnetRoot/sdk)
2323
export DOTNET_MSBUILD_SDK_RESOLVER_SDKS_DIR="$testDotnetRoot/sdk/$testDotnetVersion/Sdks"
24+
export TestDotnetSdkHash=$(head -1 "$testDotnetRoot/sdk/$testDotnetVersion/.version")
2425
export MicrosoftNETBuildExtensionsTargets="$artifacts_dir/bin/$configuration/Sdks/Microsoft.NET.Build.Extensions/msbuildExtensions/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.targets"
2526

2627
export PATH=$testDotnetRoot:$PATH
2728
export DOTNET_ROOT=$testDotnetRoot
28-
export PS1="(dogfood) $PS1"
29+
30+
testDotnetSdkCurrentHash = git -c $SDK_REPO_ROOT rev-parse HEAD
31+
hasGitChanges = $(git -c $SDK_REPO_ROOT status --porcelain) != "" or $testDotnetSdkCurrentHash != $TestDotnetSdkHash
32+
33+
if [$hasGitChanges]; then
34+
export PS1="\x1b[0;35m(dotnet dogfood*)\x1b[0m $PS1"
35+
else
36+
export PS1="\x1b[0;35m(dotnet dogfood)\x1b[0m $PS1"
37+
fi
38+
39+

eng/eng.sln

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dependabot", "dependabot\dependabot.csproj", "{8F679A97-6BF2-8E61-764F-4CB50EF6848F}"
6+
EndProject
7+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "common", "common", "{881589EE-639B-0A35-DBCE-5D94E4FC90C0}"
8+
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tools", "common\internal\Tools.csproj", "{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}"
10+
EndProject
11+
Global
12+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
13+
Debug|Any CPU = Debug|Any CPU
14+
Release|Any CPU = Release|Any CPU
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{8F679A97-6BF2-8E61-764F-4CB50EF6848F}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB}.Release|Any CPU.Build.0 = Release|Any CPU
25+
EndGlobalSection
26+
GlobalSection(SolutionProperties) = preSolution
27+
HideSolutionNode = FALSE
28+
EndGlobalSection
29+
GlobalSection(NestedProjects) = preSolution
30+
{EC3C2A6A-F9C1-3B52-791D-863B6891FEFB} = {881589EE-639B-0A35-DBCE-5D94E4FC90C0}
31+
EndGlobalSection
32+
GlobalSection(ExtensibilityGlobals) = postSolution
33+
SolutionGuid = {0D38F9D6-853D-4DB5-A726-8C01C293B732}
34+
EndGlobalSection
35+
EndGlobal

0 commit comments

Comments
 (0)