Skip to content

Commit f423868

Browse files
gep13JakeGinnivan
authored andcommitted
Corrected addition ReSharper Code Inspections
After correcting the first ReSharper Code Inspection issue for the BuildServer Class, there were a number of additional code inspections errors created. This commit aims to correct these.
1 parent 83dd8a8 commit f423868

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

AcceptanceTests/ExecCmdLineArgumentTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void RunExecViaCommandLine()
2121

2222
var buildFile = Path.Combine(fixture.RepositoryPath, "RunExecViaCommandLine.proj");
2323
File.Delete(buildFile);
24-
var buildFileContent = @"<?xml version=""1.0"" encoding=""utf-8""?>
24+
const string buildFileContent = @"<?xml version=""1.0"" encoding=""utf-8""?>
2525
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
2626
<Target Name=""OutputResults"">
2727
<Message Text=""GitVersion_FullSemVer: $(GitVersion_FullSemVer)""/>

AcceptanceTests/MsBuildProjectArgTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void RunsMsBuildProvideViaCommandLineArg()
1818

1919
var buildFile = Path.Combine(fixture.RepositoryPath, "RunsMsBuildProvideViaCommandLineArg.proj");
2020
File.Delete(buildFile);
21-
var buildFileContent = @"<?xml version=""1.0"" encoding=""utf-8""?>
21+
const string buildFileContent = @"<?xml version=""1.0"" encoding=""utf-8""?>
2222
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
2323
<Target Name=""OutputResults"">
2424
<Message Text=""GitVersion_FullSemVer: $(GitVersion_FullSemVer)""/>

GitVersionCore/BuildServers/GitHelper.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace GitVersion
77

88
public static class GitHelper
99
{
10+
private const string MergeMessageRegexPattern = "refs/heads/pull(-requests)?/(?<issuenumber>[0-9]*)/merge(-clean)?";
11+
1012
public static void NormalizeGitDirectory(string gitDirectory, Authentication authentication, string branch = null)
1113
{
1214
using (var repo = new Repository(gitDirectory))
@@ -51,30 +53,20 @@ public static bool LooksLikeAValidPullRequestNumber(string issueNumber)
5153
}
5254

5355
uint res;
54-
if (!uint.TryParse(issueNumber, out res))
55-
{
56-
return false;
57-
}
58-
59-
return true;
56+
return uint.TryParse(issueNumber, out res);
6057
}
6158

6259
public static string ExtractIssueNumber(string mergeMessage)
6360
{
6461
// Github Message: refs/heads/pull/5/merge
6562
// Stash Message: refs/heads/pull-requests/5/merge-clean
6663

67-
string pattern = "refs/heads/pull(-requests)?/(?<issuenumber>[0-9]*)/merge(-clean)?";
68-
69-
var regex = new Regex(pattern);
64+
var regex = new Regex(MergeMessageRegexPattern);
7065
var match = regex.Match(mergeMessage);
7166

7267
string issueNumber = null;
7368

74-
if (match != null)
75-
{
76-
issueNumber = match.Groups["issuenumber"].Value;
77-
}
69+
issueNumber = match.Groups["issuenumber"].Value;
7870

7971
return issueNumber;
8072
}

GitVersionExe/HelpWriter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class HelpWriter
66
{
77
public static void Write()
88
{
9-
var message =
10-
@"Use convention to derive a SemVer product version from a GitFlow or GitHub based repository.
9+
const string message = @"Use convention to derive a SemVer product version from a GitFlow or GitHub based repository.
1110
1211
GitVersion [path] [/l logFilePath]
1312

0 commit comments

Comments
 (0)