Skip to content

Commit 8acae29

Browse files
author
Jake Ginnivan
committed
Trim feature/ off the start of the tag name
1 parent b43fd21 commit 8acae29

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

GitVersionCore/ExtensionMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static void AppendLineFormat(this StringBuilder stringBuilder, string for
2929

3030
public static string TrimStart(this string value, string toTrim)
3131
{
32-
if (!value.StartsWith(toTrim))
32+
if (!value.StartsWith(toTrim, StringComparison.InvariantCultureIgnoreCase))
3333
{
3434
return value;
3535
}

GitVersionCore/GitFlow/BranchFinders/DevelopBasedVersionFinderBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ protected SemanticVersion FindVersion(
2323
var numberOfCommitsOnBranchSinceCommit = NumberOfCommitsOnBranchSinceCommit(context, ancestor);
2424
var sha = context.CurrentBranch.Tip.Sha;
2525
var releaseDate = ReleaseDateFinder.Execute(context.Repository, sha, 0);
26+
var preReleaseTag = context.CurrentBranch.Name
27+
.TrimStart(branchType.ToString() + '-')
28+
.TrimStart(branchType.ToString() + '/');
2629
var semanticVersion = new SemanticVersion
2730
{
2831
Major = versionFromMaster.Major,
2932
Minor = versionFromMaster.Minor + 1,
3033
Patch = 0,
31-
PreReleaseTag = context.CurrentBranch.Name,
34+
PreReleaseTag = preReleaseTag,
3235
BuildMetaData = new SemanticVersionBuildMetaData(
3336
numberOfCommitsOnBranchSinceCommit,
3437
context.CurrentBranch.Name, releaseDate)

Tests/GitFlow/GitFlowVersionFinderTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ public void AFeatureBranchDoesNotRequireASpecificPrefix()
147147
}
148148
}
149149

150+
[Test]
151+
public void AFeatureBranchPrefixIsNotIncludedInTag()
152+
{
153+
var repoPath = Clone(ASBMTestRepoWorkingDirPath);
154+
using (var repo = new Repository(repoPath))
155+
{
156+
repo.Branches["develop"].ForceCheckout();
157+
158+
const string branchName = "feature/ABC-1234_SomeDescription";
159+
repo.Branches.Add(branchName, repo.Head.Tip).ForceCheckout();
160+
161+
AddOneCommitToHead(repo, "code");
162+
163+
var finder = new GitVersionFinder();
164+
165+
var versionAndBranch = finder.FindVersion(new GitVersionContext
166+
{
167+
Repository = repo,
168+
CurrentBranch = repo.Head,
169+
});
170+
171+
ObjectApprover.VerifyWithJson(versionAndBranch, Scrubbers.GuidAndDateScrubber);
172+
}
173+
}
174+
150175
[Test]
151176
public void AReleaseBranchIsRequiredToBranchOffOfDevelopBranch()
152177
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"Major": 1,
3+
"Minor": 1,
4+
"Patch": 0,
5+
"PreReleaseTag": {
6+
"Name": "ABC-1234_SomeDescription",
7+
"Number": null
8+
},
9+
"BuildMetaData": {
10+
"CommitsSinceTag": 1,
11+
"Branch": "feature/ABC-1234_SomeDescription",
12+
"ReleaseDate": {
13+
"OriginalDate": "<date replaced>",
14+
"OriginalCommitSha": "000000000000000000000000000000000000000",
15+
"Date": "<date replaced>",
16+
"CommitSha": "000000000000000000000000000000000000000"
17+
},
18+
"Sha": "000000000000000000000000000000000000000",
19+
"OtherMetaData": null
20+
}
21+
}

0 commit comments

Comments
 (0)