From 664dcf854190ebff456aad556c401b7b32c80190 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 2 Nov 2018 19:42:13 +0000 Subject: [PATCH 01/12] Bump Costura.Fody from 3.1.0 to 3.1.6 in /src Bumps [Costura.Fody](https://github.com/Fody/Costura) from 3.1.0 to 3.1.6. - [Release notes](https://github.com/Fody/Costura/releases) - [Commits](https://github.com/Fody/Costura/commits) Signed-off-by: dependabot[bot] --- src/Cake.Tfs/Cake.Tfs.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Tfs/Cake.Tfs.csproj b/src/Cake.Tfs/Cake.Tfs.csproj index 364863b1..03c49980 100644 --- a/src/Cake.Tfs/Cake.Tfs.csproj +++ b/src/Cake.Tfs/Cake.Tfs.csproj @@ -23,7 +23,7 @@ - + From ba5fbb2179c2b8d8fc33f6b94d602bc845798526 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 3 Nov 2018 16:16:20 +0100 Subject: [PATCH 02/12] Update XUnit to 2.4.1 --- src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj index de78f132..087c86a3 100644 --- a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj +++ b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj @@ -20,13 +20,8 @@ - - - - - - - + + From 28a48cacfadeee913dc14180ca9b7750fce976ce Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sat, 3 Nov 2018 23:49:19 +0100 Subject: [PATCH 03/12] Add build definition for Azure Pipelines --- azure-pipelines.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..26a78d62 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,15 @@ +pool: + vmImage: 'vs2017-win2016' + +trigger: +- develop +- master +- release/* +- hotfix/* + +pr: +- develop + +steps: +- powershell: ./build.ps1 + displayName: 'Cake Build' \ No newline at end of file From 217f4ae925006809a6b7249778008e3675f857ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 3 Nov 2018 23:01:32 +0000 Subject: [PATCH 04/12] Bump Shouldly from 3.0.0 to 3.0.1 in /src Bumps [Shouldly](https://github.com/shouldly/shouldly) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/shouldly/shouldly/releases) - [Changelog](https://github.com/shouldly/shouldly/blob/master/BREAKING%20CHANGES.txt) - [Commits](https://github.com/shouldly/shouldly/compare/v3.0.0...v3.0.1) Signed-off-by: dependabot[bot] --- src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj index 087c86a3..eea936f4 100644 --- a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj +++ b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj @@ -18,7 +18,7 @@ - + From 47f227d7e389800d831f4076dddb9800db0f54c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 3 Nov 2018 23:12:13 +0000 Subject: [PATCH 05/12] Bump Microsoft.CodeAnalysis.FxCopAnalyzers from 2.6.1 to 2.6.2 in /src Bumps [Microsoft.CodeAnalysis.FxCopAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 2.6.1 to 2.6.2. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/v2.6.1...v2.6.2) Signed-off-by: dependabot[bot] --- src/Cake.Tfs/Cake.Tfs.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Tfs/Cake.Tfs.csproj b/src/Cake.Tfs/Cake.Tfs.csproj index 03c49980..8b6e5bd5 100644 --- a/src/Cake.Tfs/Cake.Tfs.csproj +++ b/src/Cake.Tfs/Cake.Tfs.csproj @@ -24,7 +24,7 @@ - + From 1795e624d44f377c1d65cbe58681d09491dbf486 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 3 Nov 2018 23:21:10 +0000 Subject: [PATCH 06/12] Bump Microsoft.NET.Test.Sdk from 15.8.0 to 15.9.0 in /src Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 15.8.0 to 15.9.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v15.8.0...v15.9.0) Signed-off-by: dependabot[bot] --- src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj index eea936f4..5f3894e5 100644 --- a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj +++ b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj @@ -14,7 +14,7 @@ - + From ccbf1dc2631ebd3bd68f32eb5625ccfb4e6f5667 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 7 Nov 2018 04:43:45 +0000 Subject: [PATCH 07/12] Bump Shouldly from 3.0.1 to 3.0.2 in /src Bumps [Shouldly](https://github.com/shouldly/shouldly) from 3.0.1 to 3.0.2. - [Release notes](https://github.com/shouldly/shouldly/releases) - [Changelog](https://github.com/shouldly/shouldly/blob/master/BREAKING%20CHANGES.txt) - [Commits](https://github.com/shouldly/shouldly/compare/v3.0.1...v3.0.2) Signed-off-by: dependabot[bot] --- src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj index 5f3894e5..64a93c69 100644 --- a/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj +++ b/src/Cake.Tfs.Tests/Cake.Tfs.Tests.csproj @@ -18,7 +18,7 @@ - + From 14f2d2d5436539013f4e18be6b5c384aa0fe38da Mon Sep 17 00:00:00 2001 From: Yan Sklyarenko Date: Sun, 11 Nov 2018 22:51:02 +0200 Subject: [PATCH 08/12] Move the GetModifiedFiles method from Cake.Issues.PullRequests.Tfs repo to the class it naturally belongs to --- .../Fakes/FakeAllSetGitClientFactory.cs | 37 ++++++++++ .../FakeNullForMethodsGitClientFactory.cs | 5 ++ .../PullRequest/TfsPullRequestTests.cs | 70 +++++++++++++++++++ src/Cake.Tfs/Cake.Tfs.csproj | 4 +- src/Cake.Tfs/PullRequest/TfsPullRequest.cs | 69 ++++++++++++++++++ 5 files changed, 183 insertions(+), 2 deletions(-) diff --git a/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeAllSetGitClientFactory.cs b/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeAllSetGitClientFactory.cs index 64de027b..ca062111 100644 --- a/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeAllSetGitClientFactory.cs +++ b/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeAllSetGitClientFactory.cs @@ -100,6 +100,43 @@ protected override Mock Setup(Mock m) State = status.State }); + // Setup CommitDiffs object + var gitChanges = new List + { + new GitChange + { + ChangeId = 1, + ChangeType = VersionControlChangeType.Edit, + Item = new GitItem("/src/project/myclass.cs", "ID1", GitObjectType.Commit, "6b13ff8", 0) + }, + null, + new GitChange + { + ChangeId = 2, + ChangeType = VersionControlChangeType.Edit, + Item = new GitItem("/tools/folder", "ID2", GitObjectType.Tree, "6b13ff8", 0) + } + }; + + var gitCommitDiffs = new GitCommitDiffs + { + ChangeCounts = new Dictionary { { VersionControlChangeType.Edit, 2 } }, + Changes = gitChanges + }; + + m.Setup(arg => arg.GetCommitDiffsAsync( + It.IsAny(), + It.IsAny(), + true, + null, + null, + It.IsAny(), + It.IsAny(), + null, + CancellationToken.None)) + .ReturnsAsync((string prj, Guid rId, bool? b, int? t, int? s, GitBaseVersionDescriptor bvd, GitTargetVersionDescriptor tvd, object o1, CancellationToken c1) + => gitCommitDiffs); + return m; } } diff --git a/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeNullForMethodsGitClientFactory.cs b/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeNullForMethodsGitClientFactory.cs index 532f83a2..b7f2d687 100644 --- a/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeNullForMethodsGitClientFactory.cs +++ b/src/Cake.Tfs.Tests/PullRequest/Fakes/FakeNullForMethodsGitClientFactory.cs @@ -1,6 +1,7 @@ namespace Cake.Tfs.Tests.PullRequest.Fakes { using System; + using System.Collections.Generic; using System.Threading; using Microsoft.TeamFoundation.SourceControl.WebApi; using Moq; @@ -15,6 +16,10 @@ protected override Mock Setup(Mock m) m.Setup(arg => arg.CreatePullRequestStatusAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(() => null); + m.Setup(arg => arg.GetCommitDiffsAsync(It.IsAny(), It.IsAny(), true, null, null, It.IsAny(), It.IsAny(), null, CancellationToken.None)) + .ReturnsAsync(() + => new GitCommitDiffs { ChangeCounts = new Dictionary(), Changes = new List() }); + return m; } } diff --git a/src/Cake.Tfs.Tests/PullRequest/TfsPullRequestTests.cs b/src/Cake.Tfs.Tests/PullRequest/TfsPullRequestTests.cs index 307dc112..1f5f7fa9 100644 --- a/src/Cake.Tfs.Tests/PullRequest/TfsPullRequestTests.cs +++ b/src/Cake.Tfs.Tests/PullRequest/TfsPullRequestTests.cs @@ -1,5 +1,8 @@ namespace Cake.Tfs.Tests.PullRequest { + using System.Collections.Generic; + using System.Linq; + using Cake.Core.IO; using Cake.Tfs.PullRequest; using Cake.Tfs.Tests.PullRequest.Fakes; using Microsoft.VisualStudio.Services.Common; @@ -23,6 +26,19 @@ public void Should_Throw_If_Log_Is_Null() result.IsArgumentNullException("log"); } + [Fact] + public void Should_Throw_If_Log_Is_Null_Overload() + { + // Given + var fixture = new PullRequestFixture(PullRequestFixture.ValidTfsUrl, "foo") { Log = null }; + + // When + var result = Record.Exception(() => new TfsPullRequest(fixture.Log, fixture.Settings)); + + // Then + result.IsArgumentNullException("log"); + } + [Fact] public void Should_Throw_If_Settings_Are_Null() { @@ -36,6 +52,19 @@ public void Should_Throw_If_Settings_Are_Null() result.IsArgumentNullException("settings"); } + [Fact] + public void Should_Throw_If_Settings_Are_Null_Overload() + { + // Given + var fixture = new PullRequestFixture(PullRequestFixture.ValidTfsUrl, 42) { Settings = null }; + + // When + var result = Record.Exception(() => new TfsPullRequest(fixture.Log, fixture.Settings)); + + // Then + result.IsArgumentNullException("settings"); + } + [Fact] public void Should_Throw_If_Git_Client_Factory_Is_Null() { @@ -421,5 +450,46 @@ public void Should_Throw_If_Null_Is_Returned_On_Tfs_Pull_Request() result.IsTfsPullRequestNotFoundException(); } } + + public sealed class GetModifiedFiles + { + [Fact] + public void Should_Return_Empty_Collection_If_No_Changes_Found() + { + // Given + var fixture = new PullRequestFixture(PullRequestFixture.ValidTfsUrl, 42) { GitClientFactory = new FakeNullForMethodsGitClientFactory() }; + var pullRequest = new TfsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory); + + // When + var files = pullRequest.GetModifiedFiles(); + + // Then + files.ShouldBeOfType>(); + files.ShouldNotBeNull(); + files.ShouldBeEmpty(); + } + + [Fact] + public void Should_Return_Valid_Collection_Of_Modified_Files() + { + // Given + var fixture = new PullRequestFixture(PullRequestFixture.ValidTfsUrl, 42); + var pullRequest = new TfsPullRequest(fixture.Log, fixture.Settings, fixture.GitClientFactory); + + // When + var files = pullRequest.GetModifiedFiles(); + + // Then + files.ShouldNotBeNull(); + files.ShouldNotBeEmpty(); + files.ShouldHaveSingleItem(); + + var filePath = files.First(); + filePath.ShouldBeOfType(); + filePath.ShouldNotBeNull(); + filePath.FullPath.ShouldNotBeEmpty(); + filePath.FullPath.ShouldBe("src/project/myclass.cs"); + } + } } } diff --git a/src/Cake.Tfs/Cake.Tfs.csproj b/src/Cake.Tfs/Cake.Tfs.csproj index 8b6e5bd5..a143ef19 100644 --- a/src/Cake.Tfs/Cake.Tfs.csproj +++ b/src/Cake.Tfs/Cake.Tfs.csproj @@ -25,8 +25,8 @@ - - + + diff --git a/src/Cake.Tfs/PullRequest/TfsPullRequest.cs b/src/Cake.Tfs/PullRequest/TfsPullRequest.cs index 013a8c37..9fc2eccf 100644 --- a/src/Cake.Tfs/PullRequest/TfsPullRequest.cs +++ b/src/Cake.Tfs/PullRequest/TfsPullRequest.cs @@ -1,9 +1,11 @@ namespace Cake.Tfs.PullRequest { using System; + using System.Collections.Generic; using System.Linq; using System.Threading; using Cake.Core.Diagnostics; + using Cake.Core.IO; using Cake.Tfs; using Microsoft.TeamFoundation.SourceControl.WebApi; using TfsUrlParser; @@ -19,6 +21,18 @@ public sealed class TfsPullRequest private readonly RepositoryDescription repositoryDescription; private readonly GitPullRequest pullRequest; + /// + /// Initializes a new instance of the class. + /// + /// The Cake log context. + /// Settings for accessing TFS. + /// If + /// is set to true and no pull request could be found. + public TfsPullRequest(ICakeLog log, TfsPullRequestSettings settings) + : this(log, settings, new GitClientFactory()) + { + } + /// /// Initializes a new instance of the class. /// @@ -380,6 +394,61 @@ public void SetStatus(TfsPullRequestStatus status) } } + /// + /// Gets the files modified by the pull request. + /// + /// The collection of the modified files paths. + public IEnumerable GetModifiedFiles() + { + if (!this.ValidatePullRequest()) + { + return new List(); + } + + var targetVersionDescriptor = new GitTargetVersionDescriptor + { + VersionType = GitVersionType.Commit, + Version = this.LastSourceCommitId + }; + + var baseVersionDescriptor = new GitBaseVersionDescriptor + { + VersionType = GitVersionType.Commit, + Version = this.LastTargetCommitId + }; + + using (var gitClient = this.gitClientFactory.CreateGitClient(this.CollectionUrl, this.settings.Credentials)) + { + var commitDiffs = gitClient.GetCommitDiffsAsync( + this.ProjectName, + this.RepositoryId, + true, // bool? diffCommonCommit + null, // int? top + null, // int? skip + baseVersionDescriptor, + targetVersionDescriptor, + null, // object userState + CancellationToken.None).Result; + + this.log.Verbose( + "Found {0} changed file(s) in the pull request", + commitDiffs.Changes.Count()); + + if (!commitDiffs.ChangeCounts.Any()) + { + return new List(); + } + + return + from change in commitDiffs.Changes + where + change != null && + !change.Item.IsFolder + select + new FilePath(change.Item.Path.TrimStart('/')); + } + } + /// /// Validates if a pull request could be found. /// Depending on From d4dbb2a1a6d9ce9ff07adab38360e06795079bfc Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Fri, 23 Nov 2018 12:37:35 +0100 Subject: [PATCH 09/12] (GH-56) Update TfsUrlParser to 1.3.0-beta1 --- src/Cake.Tfs/Cake.Tfs.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Tfs/Cake.Tfs.csproj b/src/Cake.Tfs/Cake.Tfs.csproj index a143ef19..833f9038 100644 --- a/src/Cake.Tfs/Cake.Tfs.csproj +++ b/src/Cake.Tfs/Cake.Tfs.csproj @@ -28,7 +28,7 @@ - + \ No newline at end of file From fc370a0216a5c21f8df605f1c7593cc1ac2b74bf Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Fri, 23 Nov 2018 12:48:49 +0100 Subject: [PATCH 10/12] Update release notes link --- nuspec/nuget/Cake.Tfs.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuspec/nuget/Cake.Tfs.nuspec b/nuspec/nuget/Cake.Tfs.nuspec index 82093414..34c00531 100644 --- a/nuspec/nuget/Cake.Tfs.nuspec +++ b/nuspec/nuget/Cake.Tfs.nuspec @@ -17,7 +17,7 @@ Copyright © Pascal Berger Cake Script Team-Foundation-Server TFS Azure-DevOps - https://github.com/cake-contrib/Cake.Tfs/releases/tag/0.2.3 + https://github.com/cake-contrib/Cake.Tfs/releases/tag/0.2.4 From 9017cd5daaee0d3a073f84fc205d1b9c2da8e859 Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Fri, 23 Nov 2018 12:54:48 +0100 Subject: [PATCH 11/12] Update branding to Azure DevOps Server --- README.md | 4 ++-- docs/input/docs/usage/vote-pullrequest.md | 2 +- docs/input/index.cshtml | 2 +- nuspec/nuget/Cake.Tfs.nuspec | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0a0208f7..7449122e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# TFS / Azure DevOps support for Cake +# Azure DevOps and Azure DevOps Server support for Cake -This addin for Cake allows you to work with Team Foundation Server or Azure DevOps. +This addin for Cake allows you to work with Azure DevOps or Azure DevOps Server. [![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/cake-contrib/Cake.Tfs/blob/feature/build/LICENSE) diff --git a/docs/input/docs/usage/vote-pullrequest.md b/docs/input/docs/usage/vote-pullrequest.md index ea82a9ce..18da448b 100644 --- a/docs/input/docs/usage/vote-pullrequest.md +++ b/docs/input/docs/usage/vote-pullrequest.md @@ -5,7 +5,7 @@ Description: Example how to approve or vote for pull requests using the Cake.Tfs --- The [Cake.Tfs addin] provides an alias for approving or voting on pull requests. -The following example will approve a pull request on a Team Foundation Server: +The following example will approve a pull request on a Azure DevOps Server: ```csharp #addin "Cake.Tfs" diff --git a/docs/input/index.cshtml b/docs/input/index.cshtml index 744d125a..29d88a98 100644 --- a/docs/input/index.cshtml +++ b/docs/input/index.cshtml @@ -8,6 +8,6 @@ NoGutter: true

What is it?

- The Tfs Addin for Cake allows you to access Team Foundation Server or Azure DevOps from Cake build scripts. + The Azure DevOps Addin for Cake allows you to access Azure DevOps or Azure DevOps Server from Cake build scripts.

\ No newline at end of file diff --git a/nuspec/nuget/Cake.Tfs.nuspec b/nuspec/nuget/Cake.Tfs.nuspec index 34c00531..1b9c673e 100644 --- a/nuspec/nuget/Cake.Tfs.nuspec +++ b/nuspec/nuget/Cake.Tfs.nuspec @@ -6,9 +6,9 @@ 0.0.0 Pascal Berger pascalberger, cake-contrib - Addin for working with Team Foundation Server or Azure DevOps for the Cake build automation system + Addin for working with Azure DevOps or Azure DevOps Server for the Cake build automation system - This addin for Cake allows you to work with Team Foundation Server or Azure DevOps. + This addin for Cake allows you to work with Azure DevOps or Azure DevOps Server. https://github.com/cake-contrib/Cake.Tfs/blob/develop/LICENSE http://cake-contrib.github.io/Cake.Tfs/ From dee14977390c33773be0cf059c11b88971e1e66e Mon Sep 17 00:00:00 2001 From: Pascal Berger Date: Sun, 25 Nov 2018 10:46:18 +0100 Subject: [PATCH 12/12] Update TfsUrlParser to 1.3.0 --- src/Cake.Tfs/Cake.Tfs.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cake.Tfs/Cake.Tfs.csproj b/src/Cake.Tfs/Cake.Tfs.csproj index 833f9038..cafe21e3 100644 --- a/src/Cake.Tfs/Cake.Tfs.csproj +++ b/src/Cake.Tfs/Cake.Tfs.csproj @@ -28,7 +28,7 @@ - + \ No newline at end of file