From 062facb55dc23dc49b0ad7f1a887203258c046ed Mon Sep 17 00:00:00 2001 From: Eddy Nakamura Date: Thu, 15 Oct 2020 12:03:45 -0300 Subject: [PATCH] Adding setter to GitExePath (#2110) * Adding setter to GitExePath * adding tests and change to changelog --- src/ReleaseHistory.md | 2 +- src/Sarif/GitHelper.cs | 2 +- src/Test.UnitTests.Sarif/GitHelperTests.cs | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ReleaseHistory.md b/src/ReleaseHistory.md index ccf85efc8..eb01b6dcd 100644 --- a/src/ReleaseHistory.md +++ b/src/ReleaseHistory.md @@ -4,7 +4,7 @@ * FEATURE: Add a converter for FlawFinder's CSV output format. * DEPENDENCY BREAKING: SARIF now requires Newtonsoft.JSON 11.0.2 (rather than 10.0.3) * DEPENDENCY: SARIF TypeScript package now requires minimist 1.2.3 or later (rather than >=1.2.0) ->>>>>>> master +* FEATURE: Add a setter to `GitHelper.GitExePath`. [#2110](https://github.com/microsoft/sarif-sdk/pull/2110) ## **v2.3.6** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/2.3.6) | [Driver](https://www.nuget.org/packages/Sarif.Driver/2.3.6) | [Converters](https://www.nuget.org/packages/Sarif.Converters/2.3.6) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/2.3.6) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/2.3.6) * BUGFIX: Restore multitool client app package build. diff --git a/src/Sarif/GitHelper.cs b/src/Sarif/GitHelper.cs index 647935d28..87b582cc6 100644 --- a/src/Sarif/GitHelper.cs +++ b/src/Sarif/GitHelper.cs @@ -46,7 +46,7 @@ public GitHelper(IFileSystem fileSystem = null, ProcessRunner processRunner = nu GitExePath = GetGitExePath(); } - public string GitExePath { get; } + public string GitExePath { get; set; } public Uri GetRemoteUri(string repoPath) { diff --git a/src/Test.UnitTests.Sarif/GitHelperTests.cs b/src/Test.UnitTests.Sarif/GitHelperTests.cs index fe02d3a63..be9c544cf 100644 --- a/src/Test.UnitTests.Sarif/GitHelperTests.cs +++ b/src/Test.UnitTests.Sarif/GitHelperTests.cs @@ -117,5 +117,20 @@ public void GetRepositoryRoot_WhenCalledOnTheDefaultInstanceWithCachingDisabled_ action.Should().NotThrow(); } + + [Fact] + public void GitExePath_WhenPathDoesntExist_SettingManuallyShouldWork() + { + var mockFileSystem = new Mock(); + + mockFileSystem.Setup(x => x.FileExists(It.IsAny())).Returns(false); + + var gitHelper = new GitHelper(mockFileSystem.Object); + + gitHelper.GitExePath.Should().BeNull(); + + gitHelper.GitExePath = @"C:\dev"; + gitHelper.GitExePath.Should().NotBeNullOrEmpty(); + } } }