-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial token rule implementation (#52) * Enable {branchname} and {shortsha} Token replacement to contribute towards #13 * Add shortbranchname token (#53) * #54 - Better error handling for malformed JSON (#56) * Fix #55 - Implement branchnamesuffix (#57) * Feature/overrides (#58) * Base model for overrides * Enable branch override configuration Contributes to #29 * Sample for branch overrides * Use new versioning overrides - bump label
- Loading branch information
1 parent
af1d471
commit 070978c
Showing
31 changed files
with
1,118 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// An example branch strategy | ||
{ | ||
// Specify the base version number | ||
"version": "1.0.0", | ||
// Specify the base label - Use the current branchname, height appended by default | ||
"label": [ "{branchname}" ], | ||
"branches": { | ||
// The following branches will build packages to be released | ||
"release": [ | ||
"master$", | ||
"release/.+" | ||
], | ||
"overrides" : [ | ||
{ | ||
// The master branch will always label as rc1 with sha metadata | ||
"match": "master$", | ||
"label": ["rc1"], | ||
"metadata" : ["{shortsha}"] | ||
}, | ||
{ | ||
// The release branch will have no label and put height in the metadata | ||
"match": "release/.*", | ||
"label": [], | ||
"metadata" : ["*"] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ Describe 'SimpleVersion.Command'{ | |
} | ||
} | ||
|
||
It 'Returns base values for initial commit'{ | ||
It 'Returns base values for initial commit' { | ||
Copy-Item $PSScriptRoot\assets\.simpleversion.json -Destination $pwd | ||
git add * | ||
git commit -m 'Initial commit' | ||
|
@@ -130,7 +130,7 @@ Describe 'SimpleVersion.Command'{ | |
git commit -m 'empty' --allow-empty | ||
$json = Get-Content $pwd\.simpleversion.json -Raw | ConvertFrom-Json | ||
$json.Version = "1.0.0" | ||
Set-Content $pwd\.simpleversion.json (ConvertTo-Json $json) | ||
Set-Content $pwd\.simpleversion.json (ConvertTo-Json $json -Depth 100) | ||
git add * | ||
git commit -m 'Updated version' | ||
git commit -m 'empty' --allow-empty | ||
|
@@ -154,4 +154,62 @@ Describe 'SimpleVersion.Command'{ | |
} | ||
} | ||
} | ||
|
||
Context 'Branch Overrides' { | ||
Context 'Override Matches' { | ||
|
||
BeforeAll { | ||
$dir = New-Item "${TestDrive}\$(Get-Random)" -ItemType Directory | ||
Push-Location $dir | ||
git init | ||
git config user.email "[email protected]" | ||
git config user.name "Simple Version" | ||
|
||
Copy-Item $PSScriptRoot\assets\.simpleversion.json -Destination $pwd | ||
git add * | ||
git commit -m 'Initial commit' | ||
|
||
$sha = git rev-parse HEAD | ||
$expectedSha = "c$($sha.Substring(0, 7))" | ||
} | ||
|
||
AfterAll { | ||
Pop-Location | ||
Remove-Item $dir -Recurse -Force | ||
} | ||
|
||
It 'Returns override label and meta if provided' { | ||
|
||
git checkout -b test/feature | ||
$result = Invoke | ||
Validate $result -AsSuccess { | ||
$json.BranchName | Should -Be 'test/feature' | ||
$json.Formats.Semver1 | Should -Be '0.1.0-testfeature-0001' | ||
$json.Formats.Semver2 | Should -Be '0.1.0-testfeature.1+internal' | ||
} | ||
} | ||
|
||
It 'Returns override label only if provided' { | ||
|
||
git checkout -b test/hotfix | ||
$result = Invoke | ||
Validate $result -AsSuccess { | ||
$json.BranchName | Should -Be 'test/hotfix' | ||
$json.Formats.Semver1 | Should -Be "0.1.0-$expectedSha-0001" | ||
$json.Formats.Semver2 | Should -Be "0.1.0-$expectedSha.1" | ||
} | ||
} | ||
|
||
It 'Returns override label only if provided' { | ||
|
||
git checkout -b test/release | ||
$result = Invoke | ||
Validate $result -AsSuccess { | ||
$json.BranchName | Should -Be 'test/release' | ||
$json.Formats.Semver1 | Should -Be "0.1.0-alpha1-0001" | ||
$json.Formats.Semver2 | Should -Be "0.1.0-alpha1.1+1.$expectedSha" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/SimpleVersion.Abstractions/Model/BranchConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace SimpleVersion.Model | ||
{ | ||
public class BranchConfiguration | ||
{ | ||
public string Match { get; set; } = string.Empty; | ||
|
||
public List<string> Label { get; set; } = null; | ||
|
||
public List<string> MetaData { get; set; } = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/SimpleVersion.Abstractions/Model/LabelConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SimpleVersion.Model | ||
{ | ||
public class LabelConfiguration | ||
{ | ||
public List<string> Label { get; } = new List<string>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using SimpleVersion.Pipeline; | ||
using System.Collections.Generic; | ||
|
||
namespace SimpleVersion.Rules | ||
{ | ||
public interface IRule<T> | ||
{ | ||
string Token { get; } | ||
|
||
T Resolve(VersionContext context, T value); | ||
|
||
IEnumerable<T> Apply(VersionContext context, IEnumerable<T> value); | ||
} | ||
} |
43 changes: 11 additions & 32 deletions
43
src/SimpleVersion.Core/Pipeline/Formatting/Semver1FormatProcess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 13 additions & 34 deletions
47
src/SimpleVersion.Core/Pipeline/Formatting/Semver2FormatProcess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
src/SimpleVersion.Core/Pipeline/Formatting/VersionFormatProcess.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.