public void ShouldBeConsideredAPullRequest(string suffix, string package, string branchName, long expectedPullRequestId) { IBranchClassification branchClassification = Configure(suffix: suffix, package: package); bool isRelease = branchClassification.IsPullRequest(currentBranch: branchName, out long pullRequestId); Assert.True(condition: isRelease, userMessage: "Branch should not be considered a pull request branch"); Assert.Equal(expected: expectedPullRequestId, actual: pullRequestId); }
public void ShouldNotBeConsideredRelease(string suffix, string package, string branchName) { IBranchClassification branchClassification = Configure(suffix: suffix, package: package); bool isRelease = branchClassification.IsRelease(branchName: branchName, out NuGetVersion? version); Assert.False(condition: isRelease, userMessage: "Branch should not be considered a release branch"); Assert.Null(version); }
public void ShouldBeConsideredRelease(string suffix, string package, string branchName, string expectedVersionString) { IBranchClassification branchClassification = Configure(suffix: suffix, package: package); bool isRelease = branchClassification.IsRelease(branchName: branchName, out NuGetVersion? version); Assert.True(condition: isRelease, userMessage: "Branch should be considered a release branch"); Assert.NotNull(version); Assert.Equal(expected: expectedVersionString, version !.ToString()); }
/// <summary> /// Constructor. /// </summary> /// <param name="repository">The Git Repository to search.</param> /// <param name="branchClassification">Branch classification.</param> /// <param name="externalBranchLocators">Branch location.</param> /// <param name="logger">Logging.</param> public GitBranchDiscovery(Repository repository, IBranchClassification branchClassification, IEnumerable <IExternalBranchLocator> externalBranchLocators, ILogger <GitBranchDiscovery> logger) { this._repository = repository ?? throw new ArgumentNullException(nameof(repository)); this._branchClassification = branchClassification ?? throw new ArgumentNullException(nameof(branchClassification)); this._externalBranchLocators = externalBranchLocators ?? throw new ArgumentNullException(nameof(externalBranchLocators)); this._logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public static StringBuilder NormalizeSourceBranchName(this string currentBranch, IBranchClassification branchClassification) { if (branchClassification.IsPullRequest(currentBranch: currentBranch, out long pullRequestId)) { return(new StringBuilder(@"pr-" + pullRequestId.ToString(CultureInfo.InvariantCulture))); } return(new StringBuilder(currentBranch.ToLowerInvariant())); }