Skip to content

Commit

Permalink
Merge branch 'release/0.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Aug 12, 2019
2 parents 72ce43f + c238244 commit e17c9af
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cake.Issues.Recipe/Cake.Issues.Recipe.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ See the Project Site for documentation and an overview of the whole ecosystem of
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues.Recipe.git"/>
<copyright>Copyright © Pascal Berger</copyright>
<tags>Build Cake Cake.Issues Recipe</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Recipe/releases/tag/0.2.1</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Recipe/releases/tag/0.2.2</releaseNotes>
</metadata>
</package>
4 changes: 2 additions & 2 deletions Cake.Issues.Recipe/Content/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ IssuesBuildTasks.CreateSummaryIssuesReportTask = Task("Create-SummaryIssuesRepor
IssuesBuildTasks.ReportIssuesToPullRequestTask = Task("Report-IssuesToPullRequest")
.Description("Report issues to pull request.")
.WithCriteria(() => IssuesParameters.PullRequestSystem.ShouldReportIssuesToPullRequest, "Reporting of issues to pull requests is disabled")
.WithCriteria<IssuesData>((context, data) => data.IsPullRequestBuild, "Not a pull request build")
.WithCriteria<IssuesData>((context, data) => data.BuildServer != null ? data.BuildServer.DetermineIfPullRequest(context) : false, "Not a pull request build")
.IsDependentOn("Read-Issues")
.Does<IssuesData>((data) =>
{
Expand All @@ -145,7 +145,7 @@ IssuesBuildTasks.ReportIssuesToPullRequestTask = Task("Report-IssuesToPullReques
IssuesBuildTasks.SetPullRequestIssuesStateTask = Task("Set-PullRequestIssuesState")
.Description("Set pull request status.")
.WithCriteria(() => IssuesParameters.PullRequestSystem.ShouldSetPullRequestStatus, "Setting of pull request status is disabled")
.WithCriteria<IssuesData>((context, data) => data.IsPullRequestBuild, "Not a pull request build")
.WithCriteria<IssuesData>((context, data) => data.BuildServer != null ? data.BuildServer.DetermineIfPullRequest(context) : false, "Not a pull request build")
.IsDependentOn("Read-Issues")
.Does<IssuesData>((data) =>
{
Expand Down
14 changes: 11 additions & 3 deletions Cake.Issues.Recipe/Content/data/IssuesData.cake
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public class IssuesData

/// <summary>
/// Gets the build server under which the build is running.
/// Returns <c>null</c> if running locally or on an unsupported build server.
/// </summary>
public IssuesBuildServer BuildServer { get; }
public IIssuesBuildServer BuildServer { get; }

/// <summary>
/// Gets the pull request system used for the code.
/// Returns <c>null</c> if not running a pull request build or on an unsupported build server.
/// </summary>
public IssuesPullRequestSystem PullRequestSystem { get; }
public IIssuesPullRequestSystem PullRequestSystem { get; }

/// <summary>
/// Gets the list of reported issues.
Expand All @@ -55,7 +57,13 @@ public class IssuesData
this.RepositoryRootDirectory = context.MakeAbsolute(context.Directory("./"));

this.BuildServer = DetermineBuildServer(context);
this.PullRequestSystem = DeterminePullRequestSystem(context, BuildServer.DetermineRepositoryRemoteUrl());
if (this.BuildServer != null)
{
this.PullRequestSystem =
DeterminePullRequestSystem(
context,
BuildServer.DetermineRepositoryRemoteUrl(context, this.RepositoryRootDirectory));
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class AzureDevOpsPullRequestSystem : BasePullRequestSystem
context.ReportIssuesToPullRequest(
data.Issues,
context.TfsPullRequests(
data.RepositoryUrl,
data.PullRequestId.Value,
data.BuildServer.DetermineRepositoryRemoteUrl(context, data.RepositoryRootDirectory),
data.BuildServer.DeterminePullRequestId(context).Value,
context.TfsAuthenticationOAuth(context.EnvironmentVariable("SYSTEM_ACCESSTOKEN"))),
data.RepositoryRootDirectory);
}
Expand All @@ -52,8 +52,8 @@ public class AzureDevOpsPullRequestSystem : BasePullRequestSystem

var pullRequestSettings =
new TfsPullRequestSettings(
data.RepositoryUrl,
data.PullRequestId.Value,
data.BuildServer.DetermineRepositoryRemoteUrl(context, data.RepositoryRootDirectory),
data.BuildServer.DeterminePullRequestId(context).Value,
context.TfsAuthenticationOAuth(context.EnvironmentVariable("SYSTEM_ACCESSTOKEN")));

var pullRequstStatus =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <summary>
/// Basic implementation for all pull request server.
/// </summary>
public abstract class BasePullRequestSystem
public abstract class BasePullRequestSystem : IIssuesPullRequestSystem
{
/// <inheritdoc />
public abstract void ReportIssuesToPullRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#load IIssuesPullRequestSystem.cake
#load BsePullRequestSystem.cake
#load BasePullRequestSystem.cake
#load AzureDevOpsPullRequestSystem.cake

0 comments on commit e17c9af

Please sign in to comment.