Repository: JanDeDobbeleer/oh-my-posh
Pull request #812 (2021-06-18 05:03:30)

fix dotnet int issue
- chore: test on all supported goarchs
- fix(dotnet): correct exit code on Windows

### Prerequisites

- [x] I have read and understand the `CONTRIBUTING` guide
- [x] The commit message follows the [conventional commits][cc] guidelines
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] Docs have been added / updated (for bug fixes / features)

### Description

[Description of the change]

### Tips

If you're not comfortable working with git, we're working a [guide][docs] to help you out.
Oh My Posh advises [GitKraken][kraken] as your preferred cross platfrom git GUI powertool.

[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary
[docs]: https://ohmyposh.dev/docs/contributing_git
[kraken]: https://www.gitkraken.com/invite/nQmDPR9D



Patch:
diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml
new file mode 100644
index 00000000..113456d4
--- /dev/null
+++ b/.github/workflows/artifacts.yml
@@ -0,0 +1,37 @@
+on:
+  pull_request:
+    paths-ignore:
+      - 'README.md'
+      - 'CONTRIBUTING.md'
+      - 'COPYING'
+      - 'docs/**'
+      - '.github/*.md'
+      - '.github/FUNDING.yml'
+
+name: Build Code
+jobs:
+  build:
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macos-latest, windows-latest]
+        goarch: [amd64]
+        include:
+        - os: ubuntu-latest
+          goarch: arm
+        - os: windows-latest
+          goarch: 386
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        working-directory: ${{ github.workspace }}/src
+    steps:
+    - name: Install Go
+      uses: actions/setup-go@v2
+      with:
+        go-version: 1.16
+    - name: Checkout code
+      uses: actions/checkout@v2
+    - name: Build
+      run: go build
+      env:
+        GOARCH: ${{ matrix.goarch }}
diff --git a/.github/workflows/code.yml b/.github/workflows/code.yml
index deb77ca8..253bdb4d 100644
--- a/.github/workflows/code.yml
+++ b/.github/workflows/code.yml
@@ -14,10 +14,6 @@ jobs:
     strategy:
       matrix:
         os: [ubuntu-latest, macos-latest, windows-latest]
-        include:
-        - os: ubuntu-latest
-        - os: macos-latest
-        - os: windows-latest
     runs-on: ${{ matrix.os }}
     defaults:
       run:
diff --git a/src/segment_dotnet.go b/src/segment_dotnet.go
index f3b88845..ac8d3891 100644
--- a/src/segment_dotnet.go
+++ b/src/segment_dotnet.go
@@ -8,15 +8,19 @@ const (
 	// UnsupportedDotnetVersionIcon is displayed when the dotnet version in
 	// the current folder isn't supported by the installed dotnet SDK set.
 	UnsupportedDotnetVersionIcon Property = "unsupported_version_icon"
+
+	dotnetExitCodeUnix    = 145
+	dotnetExitCodeWindows = -2147450735
 )
 
 func (d *dotnet) string() string {
 	version := d.language.string()
 
-	// Exit code 145 is a special indicator that dotnet
+	// Exit codes 145 and 0x80008091 are special indicators that dotnet
 	// ran, but the current project config settings specify
 	// use of an SDK that isn't installed.
-	if d.language.exitCode == 145 {
+	exitCode := d.language.exitCode
+	if exitCode == dotnetExitCodeWindows || exitCode == dotnetExitCodeUnix {
 		return d.language.props.getString(UnsupportedDotnetVersionIcon, "\uf071 ")
 	}
 


Test patch:
diff --git a/src/segment_dotnet_test.go b/src/segment_dotnet_test.go
index edcb244e..e13140f6 100644
--- a/src/segment_dotnet_test.go
+++ b/src/segment_dotnet_test.go
@@ -9,7 +9,7 @@ import (
 type dotnetArgs struct {
 	enabled         bool
 	version         string
-	unsupported     bool
+	exitCode        int
 	unsupportedIcon string
 	displayVersion  bool
 }
@@ -17,8 +17,8 @@ type dotnetArgs struct {
 func bootStrapDotnetTest(args *dotnetArgs) *dotnet {
 	env := new(MockedEnvironment)
 	env.On("hasCommand", "dotnet").Return(args.enabled)
-	if args.unsupported {
-		err := &commandError{exitCode: 145}
+	if args.exitCode != 0 {
+		err := &commandError{exitCode: args.exitCode}
 		env.On("runCommand", "dotnet", []string{"--version"}).Return("", err)
 	} else {
 		env.On("runCommand", "dotnet", []string{"--version"}).Return(args.version, nil)
@@ -75,7 +75,20 @@ func TestDotnetVersionUnsupported(t *testing.T) {
 	args := &dotnetArgs{
 		enabled:         true,
 		displayVersion:  true,
-		unsupported:     true,
+		exitCode:        dotnetExitCodeUnix,
+		unsupportedIcon: expected,
+	}
+	dotnet := bootStrapDotnetTest(args)
+	assert.True(t, dotnet.enabled())
+	assert.Equal(t, expected, dotnet.string())
+}
+
+func TestDotnetVersionUnsupportedWindows(t *testing.T) {
+	expected := "x"
+	args := &dotnetArgs{
+		enabled:         true,
+		displayVersion:  true,
+		exitCode:        dotnetExitCodeWindows,
 		unsupportedIcon: expected,
 	}
 	dotnet := bootStrapDotnetTest(args)