public void PrepareStagingBranch(BuildState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } var versionInfo = FetchVersion(); if (versionInfo.BranchName == state.ReleaseTargetBranch) { throw new Exception( $@"Cannot initiate a release from the release-target branch. Switch to a develop or release-xxx branch before continuing. Based on the current version information I expect to be on branch '{state.DevelopmentBranch}', but detected branch '{versionInfo.BranchName}' instead"); } // if on development branch, create a release branch. // if you work in a support-xx branch, treat it as your develop-branch. var stageBranchName = state.ReleaseStagingBranch; if (versionInfo.BranchName == state.DevelopmentBranch) { if (GitTools.CheckBranchExists(stageBranchName)) { Logger.Info($"Switching to existing staging branch from {versionInfo.BranchName} as branch {stageBranchName}"); GitTools.Checkout(stageBranchName); } else { Logger.Info($"Creating new staging branch from current branch {versionInfo.BranchName} as branch {stageBranchName}"); GitTools.Branch(stageBranchName); UpdateVersionNumbers?.Invoke(this, BuildType.Staging); } } else { if (versionInfo.BranchName != stageBranchName) { throw new Exception( $@"This command must be exist run from the development branch or an active release branch. Based on the current version information I expect to be on branch '{state.ReleaseStagingBranch}', but detected branch '{versionInfo.BranchName}' instead"); } } }
public void ValidateBuildState() { GitTools.CheckBranchExists(developBranch); GitTools.CheckBranchExists(ReleaseTargetBranch); }