From 8852f129c0f2ac1b393b2f612e4ee0e052e1a0c2 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 13:22:05 +0200 Subject: [PATCH 1/8] (GH-60) Fix loading of BasePullRequestSystem --- .../{BaseRequestSystem..cake => BasePullRequestSystem.cake} | 0 .../Content/tasks/pullrequestsystems/pullrequestsystems.cake | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Cake.Issues.Recipe/Content/tasks/pullrequestsystems/{BaseRequestSystem..cake => BasePullRequestSystem.cake} (100%) diff --git a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BaseRequestSystem..cake b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BasePullRequestSystem.cake similarity index 100% rename from Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BaseRequestSystem..cake rename to Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BasePullRequestSystem.cake diff --git a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/pullrequestsystems.cake b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/pullrequestsystems.cake index 88d6c5f8..d7687d0b 100644 --- a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/pullrequestsystems.cake +++ b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/pullrequestsystems.cake @@ -1,3 +1,3 @@ #load IIssuesPullRequestSystem.cake -#load BsePullRequestSystem.cake +#load BasePullRequestSystem.cake #load AzureDevOpsPullRequestSystem.cake \ No newline at end of file From a11178dae57762624ece56c016ed22312d7fc2ab Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 13:28:42 +0200 Subject: [PATCH 2/8] (GH-62) Use correct interfaces --- Cake.Issues.Recipe/Content/data/IssuesData.cake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cake.Issues.Recipe/Content/data/IssuesData.cake b/Cake.Issues.Recipe/Content/data/IssuesData.cake index 119bd8c7..ab9dc6a0 100644 --- a/Cake.Issues.Recipe/Content/data/IssuesData.cake +++ b/Cake.Issues.Recipe/Content/data/IssuesData.cake @@ -23,12 +23,12 @@ public class IssuesData /// /// Gets the build server under which the build is running. /// - public IssuesBuildServer BuildServer { get; } + public IIssuesBuildServer BuildServer { get; } /// /// Gets the pull request system used for the code. /// - public IssuesPullRequestSystem PullRequestSystem { get; } + public IIssuesPullRequestSystem PullRequestSystem { get; } /// /// Gets the list of reported issues. From a7ed38813938afabed1a38c42f3940b1a9b79f18 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 13:44:13 +0200 Subject: [PATCH 3/8] (GH-64) Fix check if running build for pull request --- Cake.Issues.Recipe/Content/build.cake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cake.Issues.Recipe/Content/build.cake b/Cake.Issues.Recipe/Content/build.cake index 4c6d1586..0e011cc6 100644 --- a/Cake.Issues.Recipe/Content/build.cake +++ b/Cake.Issues.Recipe/Content/build.cake @@ -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((context, data) => data.IsPullRequestBuild, "Not a pull request build") + .WithCriteria((context, data) => data.BuildServer != null ? data.BuildServer.DetermineIfPullRequest(context) : false, "Not a pull request build") .IsDependentOn("Read-Issues") .Does((data) => { @@ -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((context, data) => data.IsPullRequestBuild, "Not a pull request build") + .WithCriteria((context, data) => data.BuildServer != null ? data.BuildServer.DetermineIfPullRequest(context) : false, "Not a pull request build") .IsDependentOn("Read-Issues") .Does((data) => { From 402bacb9b428d2a646105edd1571eb69108070f0 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 20:14:04 +0200 Subject: [PATCH 4/8] (GH-66) Fix access to repository remote URL --- Cake.Issues.Recipe/Content/data/IssuesData.cake | 5 ++++- .../pullrequestsystems/AzureDevOpsPullRequestSystem.cake | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cake.Issues.Recipe/Content/data/IssuesData.cake b/Cake.Issues.Recipe/Content/data/IssuesData.cake index ab9dc6a0..10aab685 100644 --- a/Cake.Issues.Recipe/Content/data/IssuesData.cake +++ b/Cake.Issues.Recipe/Content/data/IssuesData.cake @@ -55,7 +55,10 @@ public class IssuesData this.RepositoryRootDirectory = context.MakeAbsolute(context.Directory("./")); this.BuildServer = DetermineBuildServer(context); - this.PullRequestSystem = DeterminePullRequestSystem(context, BuildServer.DetermineRepositoryRemoteUrl()); + this.PullRequestSystem = + DeterminePullRequestSystem( + context, + BuildServer.DetermineRepositoryRemoteUrl(context, this.RepositoryRootDirectory)); } /// diff --git a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake index 99783f81..25e7b385 100644 --- a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake +++ b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake @@ -25,7 +25,7 @@ public class AzureDevOpsPullRequestSystem : BasePullRequestSystem context.ReportIssuesToPullRequest( data.Issues, context.TfsPullRequests( - data.RepositoryUrl, + data.BuildServer.DetermineRepositoryRemoteUrl(context, data.RepositoryRootDirectory), data.PullRequestId.Value, context.TfsAuthenticationOAuth(context.EnvironmentVariable("SYSTEM_ACCESSTOKEN"))), data.RepositoryRootDirectory); @@ -52,7 +52,7 @@ public class AzureDevOpsPullRequestSystem : BasePullRequestSystem var pullRequestSettings = new TfsPullRequestSettings( - data.RepositoryUrl, + data.BuildServer.DetermineRepositoryRemoteUrl(context, data.RepositoryRootDirectory), data.PullRequestId.Value, context.TfsAuthenticationOAuth(context.EnvironmentVariable("SYSTEM_ACCESSTOKEN"))); From f69a5c15696955827cb49f1449342174660428ab Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 20:23:07 +0200 Subject: [PATCH 5/8] (GH-68) Fix access to pull request ID --- .../pullrequestsystems/AzureDevOpsPullRequestSystem.cake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake index 25e7b385..4b8b6cfd 100644 --- a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake +++ b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/AzureDevOpsPullRequestSystem.cake @@ -26,7 +26,7 @@ public class AzureDevOpsPullRequestSystem : BasePullRequestSystem data.Issues, context.TfsPullRequests( data.BuildServer.DetermineRepositoryRemoteUrl(context, data.RepositoryRootDirectory), - data.PullRequestId.Value, + data.BuildServer.DeterminePullRequestId(context).Value, context.TfsAuthenticationOAuth(context.EnvironmentVariable("SYSTEM_ACCESSTOKEN"))), data.RepositoryRootDirectory); } @@ -53,7 +53,7 @@ public class AzureDevOpsPullRequestSystem : BasePullRequestSystem var pullRequestSettings = new TfsPullRequestSettings( data.BuildServer.DetermineRepositoryRemoteUrl(context, data.RepositoryRootDirectory), - data.PullRequestId.Value, + data.BuildServer.DeterminePullRequestId(context).Value, context.TfsAuthenticationOAuth(context.EnvironmentVariable("SYSTEM_ACCESSTOKEN"))); var pullRequstStatus = From f6509fb20db23eddb72b6d7e992a18a4f93bc142 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 20:28:04 +0200 Subject: [PATCH 6/8] (GH-70) Implement IIssuesPullRequestSystem in BasePullRequestSystem --- .../Content/tasks/pullrequestsystems/BasePullRequestSystem.cake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BasePullRequestSystem.cake b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BasePullRequestSystem.cake index aa4ecc15..2b24cdbe 100644 --- a/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BasePullRequestSystem.cake +++ b/Cake.Issues.Recipe/Content/tasks/pullrequestsystems/BasePullRequestSystem.cake @@ -1,7 +1,7 @@ /// /// Basic implementation for all pull request server. /// -public abstract class BasePullRequestSystem +public abstract class BasePullRequestSystem : IIssuesPullRequestSystem { /// public abstract void ReportIssuesToPullRequest( From 6bd78de730d4f629705b2a71a0d06326e17c16db Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 20:31:27 +0200 Subject: [PATCH 7/8] Update release notes link --- Cake.Issues.Recipe/Cake.Issues.Recipe.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cake.Issues.Recipe/Cake.Issues.Recipe.nuspec b/Cake.Issues.Recipe/Cake.Issues.Recipe.nuspec index 5e154824..452c2786 100644 --- a/Cake.Issues.Recipe/Cake.Issues.Recipe.nuspec +++ b/Cake.Issues.Recipe/Cake.Issues.Recipe.nuspec @@ -19,6 +19,6 @@ See the Project Site for documentation and an overview of the whole ecosystem of Copyright © Pascal Berger Build Cake Cake.Issues Recipe - https://github.com/cake-contrib/Cake.Issues.Recipe/releases/tag/0.2.1 + https://github.com/cake-contrib/Cake.Issues.Recipe/releases/tag/0.2.2 \ No newline at end of file From c2382447fdf992c8fc0d3f7a04330fd4a170f1c1 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 11 Aug 2019 20:49:05 +0200 Subject: [PATCH 8/8] Fix exception if running locally or on unsupported build server --- Cake.Issues.Recipe/Content/data/IssuesData.cake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Cake.Issues.Recipe/Content/data/IssuesData.cake b/Cake.Issues.Recipe/Content/data/IssuesData.cake index 10aab685..0edada96 100644 --- a/Cake.Issues.Recipe/Content/data/IssuesData.cake +++ b/Cake.Issues.Recipe/Content/data/IssuesData.cake @@ -22,11 +22,13 @@ public class IssuesData /// /// Gets the build server under which the build is running. + /// Returns null if running locally or on an unsupported build server. /// public IIssuesBuildServer BuildServer { get; } /// /// Gets the pull request system used for the code. + /// Returns null if not running a pull request build or on an unsupported build server. /// public IIssuesPullRequestSystem PullRequestSystem { get; } @@ -55,10 +57,13 @@ public class IssuesData this.RepositoryRootDirectory = context.MakeAbsolute(context.Directory("./")); this.BuildServer = DetermineBuildServer(context); - this.PullRequestSystem = - DeterminePullRequestSystem( - context, - BuildServer.DetermineRepositoryRemoteUrl(context, this.RepositoryRootDirectory)); + if (this.BuildServer != null) + { + this.PullRequestSystem = + DeterminePullRequestSystem( + context, + BuildServer.DetermineRepositoryRemoteUrl(context, this.RepositoryRootDirectory)); + } } ///