Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Add AutoStash parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Nov 6, 2019
1 parent ed79a2c commit 7abb1b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ project {
value = "",
allowEmpty = true,
display = ParameterDisplay.NORMAL)
text (
"env.AutoStash",
label = "AutoStash",
value = "True",
allowEmpty = true,
display = ParameterDisplay.NORMAL)
param(
"teamcity.runner.commandline.stdstreams.encoding",
"IBM-437"
Expand Down
21 changes: 16 additions & 5 deletions build/Build.GitFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

partial class Build
{
[Parameter] readonly bool AutoStash = true;

Target Changelog => _ => _
.OnlyWhenStatic(
() => GitRepository.IsOnReleaseBranch() ||
GitRepository.IsOnHotfixBranch())
.OnlyWhenStatic(() => GitRepository.IsOnReleaseBranch() || GitRepository.IsOnHotfixBranch())
.Executes(() =>
{
FinalizeChangelog(ChangelogFile, GitVersion.MajorMinorPatch, GitRepository);
Expand All @@ -31,7 +31,7 @@ partial class Build
.Executes(() =>
{
if (!GitRepository.IsOnReleaseBranch())
Git($"checkout -b {ReleaseBranchPrefix}/{GitVersion.MajorMinorPatch} {DevelopBranch}");
Checkout($"{ReleaseBranchPrefix}/{GitVersion.MajorMinorPatch}", start: DevelopBranch);
else
FinishReleaseOrHotfix();
});
Expand All @@ -48,7 +48,7 @@ partial class Build
.DisableLogOutput()).Result;

if (!GitRepository.IsOnHotfixBranch())
Git($"checkout -b {HotfixBranchPrefix}/{masterVersion.Major}.{masterVersion.Minor}.{masterVersion.Patch + 1} {MasterBranch}");
Checkout($"{HotfixBranchPrefix}/{masterVersion.Major}.{masterVersion.Minor}.{masterVersion.Patch + 1}", start: MasterBranch);
else
FinishReleaseOrHotfix();
});
Expand All @@ -66,4 +66,15 @@ void FinishReleaseOrHotfix()

Git($"push origin {MasterBranch} {DevelopBranch} {GitVersion.MajorMinorPatch}");
}

void Checkout(string branch, string start)
{
if (AutoStash)
Git("git stash");

Git($"checkout -b {branch} {start}");

if (AutoStash)
Git("git stash apply");
}
}
1 change: 1 addition & 0 deletions shell-completion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ApiKey:
AutoStash:
Configuration:
- Debug
- Release
Expand Down

0 comments on commit 7abb1b2

Please sign in to comment.