diff --git a/.appveyor.yml b/.appveyor.yml index 2b5f541..06c5830 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,7 +1,7 @@ #---------------------------------# # Build Image # #---------------------------------# -image: Visual Studio 2017 +image: Visual Studio 2019 #---------------------------------# # Build Script # @@ -27,4 +27,4 @@ branches: # Build Cache # #---------------------------------# cache: -- tools -> setup.cake \ No newline at end of file +- tools -> recipe.cake diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..da37e81 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# These owners will be the default owners for everything in the repo and +# will be requested for review when someone opens a pull request. +* @pascalberger @christianbumann @x-jokay @silanosa @georgesgoetz \ No newline at end of file diff --git a/.gitignore b/.gitignore index a9e78cf..ad84880 100644 --- a/.gitignore +++ b/.gitignore @@ -276,4 +276,6 @@ __pycache__/ # Cake - Uncomment if you are using it tools/** !tools/packages.config -BuildArtifacts/ \ No newline at end of file +BuildArtifacts/ + +.dotnet diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eb79eee..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: csharp -script: - - ./build.sh -v diagnostic -os: - - linux - - osx -cache: - directories: - - packages - - tools diff --git a/README.md b/README.md index b0c073e..895b807 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,32 @@ -# TFS / Azure DevOps support for Cake Issues Addin +# Azure DevOps support for Cake Issues Addin This addin for the Cake Build Automation System allows you to write issues found using any code -analyzer or linter to Team Foundation Server or Azure DevOps pull requests using -the [Cake Issues addin](https://github.com/cake-contrib/Cake.Issues). +analyzer or linter to Azure DevOps pull requests using the [Cake Issues addin](https://github.com/cake-contrib/Cake.Issues). For more information about this add-in see the [Cake.Issues website](https://cakeissues.net) -and for general information about the Cake build automation system see the [Cake website](http://cakebuild.net) +and for general information about the Cake build automation system see the [Cake website](http://cakebuild.net). -[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.Tfs/blob/feature/build/LICENSE) +[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/blob/feature/build/LICENSE) ## Information | | Stable | Pre-release | |:--:|:--:|:--:| -|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/cake-contrib/Cake.Issues.PullRequests.Tfs.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.Tfs/releases/latest)| -|NuGet|[![NuGet](https://img.shields.io/nuget/v/Cake.Issues.PullRequests.Tfs.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.Tfs)|[![NuGet](https://img.shields.io/nuget/vpre/Cake.Issues.PullRequests.Tfs.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.Tfs)| +|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/cake-contrib/Cake.Issues.PullRequests.AzureDevOps.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/releases/latest)| +|NuGet|[![NuGet](https://img.shields.io/nuget/v/Cake.Issues.PullRequests.AzureDevOps.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.AzureDevOps)|[![NuGet](https://img.shields.io/nuget/vpre/Cake.Issues.PullRequests.AzureDevOps.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.AzureDevOps)| ## Build Status | | Develop | Master | |:--:|:--:|:--:| -|AppVeyor Windows|[![Build status](https://ci.appveyor.com/api/projects/status/s8t8j2gh6icynkod/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-tfs/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/s8t8j2gh6icynkod/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-tfs/branch/master)| -|Azure DevOps Windows|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.Tfs?branchName=develop&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_build/latest?definitionId=8?branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.Tfs?branchName=master&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_build/latest?definitionId=8?branchName=master)| +|AppVeyor Windows|[![Build status](https://ci.appveyor.com/api/projects/status/6t6m39enwkvkhk80/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-azuredevops/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/6t6m39enwkvkhk80/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-azuredevops/branch/master)| +|Azure DevOps Windows|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=develop&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=master&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=master)| +|Azure DevOps macOS|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=develop&jobName=macOS)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=master&jobName=macOS)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=master)| +|Azure DevOps Ubuntu|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=develop&jobName=Ubuntu)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=master&jobName=Ubuntu)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=master)| ## Code Coverage -[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/Cake.Issues.PullRequests.Tfs/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/Cake.Issues.PullRequests.Tfs?branch=develop) +[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/Cake.Issues.PullRequests.AzureDevOps?branch=develop) ## Quick Links @@ -33,7 +34,7 @@ and for general information about the Cake build automation system see the [Cake ## Chat Room -Come join in the conversation about this addin in our Gitter Chat Room +Come join in the conversation about this addin in our Gitter Chat Room. [![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8f395df..cfc3da0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,11 +6,35 @@ trigger: pr: - develop +- release/* +- hotfix/* jobs: - job: Windows pool: vmImage: 'vs2017-win2016' steps: - - powershell: ./build.ps1 + - powershell: | + $ENV:CAKE_SKIP_GITVERSION=([string]::IsNullOrEmpty($ENV:SYSTEM_PULLREQUEST_PULLREQUESTID) -eq $False).ToString() + .\build.ps1 + exit $LASTEXITCODE + displayName: 'Cake Build' +- job: macOS + pool: + vmImage: 'macOS-10.14' + steps: + # To manually select a Xamarin SDK version on the Hosted macOS agent, enable this script with the SDK version you want to target + # https://go.microsoft.com/fwlink/?linkid=871629 + - bash: | + sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 5_18_1 + displayName: 'Select Mono 5.18.1' + - bash: | + ./build.sh + displayName: 'Cake Build' +- job: Ubuntu + pool: + vmImage: 'ubuntu-16.04' + steps: + - bash: | + ./build.sh displayName: 'Cake Build' \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index bdfb32b..a6d30c4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -35,7 +35,7 @@ http://cakebuild.net [CmdletBinding()] Param( - [string]$Script = "setup.cake", + [string]$Script = "recipe.cake", [string]$Target = "Default", [ValidateSet("Release", "Debug")] [string]$Configuration = "Release", @@ -181,4 +181,4 @@ if (!(Test-Path $CAKE_EXE)) { # Start Cake Write-Host "Running build script..." Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" -exit $LASTEXITCODE \ No newline at end of file +exit $LASTEXITCODE diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index a541ec1..68d388f --- a/build.sh +++ b/build.sh @@ -1,33 +1,35 @@ #!/usr/bin/env bash -############################################################### -# This is the Cake bootstrapper script that is responsible for -# downloading Cake and all specified tools from NuGet. -############################################################### +########################################################################## +# This is the Cake bootstrapper script for Linux and OS X. +# This file was downloaded from https://github.com/cake-build/resources +# Feel free to change this file to fit your needs. +########################################################################## # Define directories. SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) TOOLS_DIR=$SCRIPT_DIR/tools NUGET_EXE=$TOOLS_DIR/nuget.exe -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe +NUGET_URL=https://dist.nuget.org/win-x86-commandline/latest/nuget.exe +CAKE_VERSION=0.32.1 +CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe + +# Temporarily skip verification of addins. +export CAKE_SETTINGS_SKIPVERIFICATION='true' # Define default arguments. -SCRIPT="setup.cake" TARGET="Default" CONFIGURATION="Release" VERBOSITY="verbose" DRYRUN= -SHOW_VERSION=false SCRIPT_ARGUMENTS=() # Parse arguments. for i in "$@"; do case $1 in - -s|--script) SCRIPT="$2"; shift ;; -t|--target) TARGET="$2"; shift ;; -c|--configuration) CONFIGURATION="$2"; shift ;; -v|--verbosity) VERBOSITY="$2"; shift ;; -d|--dryrun) DRYRUN="-dryrun" ;; - --version) SHOW_VERSION=true ;; --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; *) SCRIPT_ARGUMENTS+=("$1") ;; esac @@ -35,48 +37,66 @@ for i in "$@"; do done # Make sure the tools folder exist. -if [ ! -d $TOOLS_DIR ]; then - mkdir $TOOLS_DIR +if [ ! -d "$TOOLS_DIR" ]; then + mkdir "$TOOLS_DIR" fi -# Make sure that packages.config exist. -if [ ! -f $TOOLS_DIR/packages.config ]; then - echo "Downloading packages.config..." - curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occured while downloading packages.config." - exit 1 - fi +# Print Mono version. +echo "Mono version:" +mono --version +echo "" + +########################################################################### +# INSTALL .NET CORE CLI +########################################################################### + +echo "Installing .NET CLI..." +if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then + mkdir "$SCRIPT_DIR/.dotnet" fi +curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh +sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.400 --install-dir .dotnet --no-path +export PATH="$SCRIPT_DIR/.dotnet":$PATH +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0 +"$SCRIPT_DIR/.dotnet/dotnet" --info + +########################################################################### +# INSTALL NUGET +########################################################################### # Download NuGet if it does not exist. -if [ ! -f $NUGET_EXE ]; then +if [ ! -f "$NUGET_EXE" ]; then echo "Downloading NuGet..." - curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe + curl -Lsfo "$NUGET_EXE" $NUGET_URL if [ $? -ne 0 ]; then - echo "An error occured while downloading nuget.exe." + echo "An error occurred while downloading nuget.exe." exit 1 fi fi -# Restore tools from NuGet. -pushd $TOOLS_DIR >/dev/null -mono $NUGET_EXE install -ExcludeVersion -PreRelease -Source https://www.myget.org/F/cake/api/v3/index.json -if [ $? -ne 0 ]; then - echo "Could not restore NuGet packages." - exit 1 +########################################################################### +# INSTALL CAKE +########################################################################### + +if [ ! -f "$CAKE_EXE" ]; then + mono "$NUGET_EXE" install Cake -Version $CAKE_VERSION -OutputDirectory "$TOOLS_DIR" + if [ $? -ne 0 ]; then + echo "An error occurred while installing Cake." + exit 1 + fi fi -popd >/dev/null # Make sure that Cake has been installed. -if [ ! -f $CAKE_EXE ]; then +if [ ! -f "$CAKE_EXE" ]; then echo "Could not find Cake.exe at '$CAKE_EXE'." exit 1 fi +########################################################################### +# RUN BUILD SCRIPT +########################################################################### + # Start Cake -if $SHOW_VERSION; then - exec mono $CAKE_EXE -version -else - exec mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" -fi +exec mono "$CAKE_EXE" recipe.cake --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" diff --git a/docs/cake.issues.pullrequests.azuredevops.png b/docs/cake.issues.pullrequests.azuredevops.png new file mode 100644 index 0000000..af5eda3 Binary files /dev/null and b/docs/cake.issues.pullrequests.azuredevops.png differ diff --git a/docs/examples/azure-pipelines.md b/docs/examples/azure-pipelines.md new file mode 100644 index 0000000..6078ba5 --- /dev/null +++ b/docs/examples/azure-pipelines.md @@ -0,0 +1,83 @@ +--- +Order: 30 +Title: Using with Azure Pipelines +Description: Example how to use the Cake.Issues.PullRequests.AzureDevOps addin from an Azure Pipelines build. +--- +This example shows how to write issues as comments to an Azure DevOps pull request from an Azure Pipelines build. + +To write issues as comments to Azure DevOps pull requests you need to import the core addin, +the core pull request addin, the Azure DevOps support including the Cake.AzureDevOps addin, and one or more issue providers, +in this example for JetBrains InspectCode: + +```csharp +#addin "Cake.Issues" +#addin "Cake.Issues.InspectCode" +#addin "Cake.Issues.PullRequests" +#addin "Cake.Issues.PullRequests.AzureDevOps" +#addin "Cake.AzureDevOps" +``` + +:::{.alert .alert-warning} +Please note that you always should pin addins to a specific version to make sure your builds are deterministic and +won't break due to updates to one of the addins. + +See [pinning addin versions](https://cakebuild.net/docs/tutorials/pinning-cake-version#pinning-addin-version) for details. +::: + +In the following task we'll first determine if the build is running on Azure DevOps and for a pull request, +then read the remote repository URL and pull request id from environment variables set by the Azure Pipelines build +and finally call the [AzureDevOpsPullRequests] alias using the OAuth token provided by the Azure Pipeline build. + +:::{.alert .alert-info} +Please note that you'll need to setup your Azure Pipelines build to allow scripts to +access the OAuth token and need to setup proper permissions. + +See [OAuth authentication from Azure Pipelines] for details. +::: + +```csharp +Task("ReportIssuesToPullRequest").Does(() => +{ + var isRunningOnAzureDevOps = + !string.IsNullOrWhiteSpace(context.EnvironmentVariable("TF_BUILD")) && + !string.IsNullOrWhiteSpace(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")) && + ( + new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host == "dev.azure.com" || + new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host.EndsWith("visualstudio.com") + ); + + var isPullRequestBuild = + !string.IsNullOrWhiteSpace(context.EnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID")); + + if (isRunningOnAzureDevOps) + { + var repositoryUrl = new Uri(context.EnvironmentVariable("BUILD_REPOSITORY_URI")); + + if (isPullRequestBuild) + { + var pullRequestIdVariable = context.EnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID"); + if (!Int32.TryParse(pullRequestIdVariable, out var pullRequestId)) + { + throw new Exception($"Invalid pull request ID: {pullRequestIdVariable}"); + } + else + { + var repoRootFolder = MakeAbsolute(Directory("./")); + + ReportIssuesToPullRequest( + InspectCodeIssuesFromFilePath( + @"C:\build\inspectcode.log"), + AzureDevOpsPullRequests( + repositoryUrl, + pullRequestId, + AzureDevOpsAuthenticationOAuth(EnvironmentVariable("SYSTEM_ACCESSTOKEN"))), + repoRootFolder); + } + } + } +}); +``` + +[AzureDevOpsPullRequests]: ../../../../api/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases/64912B0A +[Allow scripts to access the OAuth token]: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/options#allow-scripts-to-access-the-oauth-token +[OAuth authentication from Azure Pipelines]: ../setup#oauth-authentication-from-azure-pipelines diff --git a/docs/examples/index.cshtml b/docs/examples/index.cshtml new file mode 100644 index 0000000..17e2702 --- /dev/null +++ b/docs/examples/index.cshtml @@ -0,0 +1,12 @@ +--- +Title: Examples +Description: Examples for using the Cake.Issues.PullRequests.AzureDevOps addin. +--- +

@Html.Raw(Model.String(DocsKeys.Description))

+ +
+There's a demo repository +available which you can fork and to which you can create pull requests to test the integration functionality. +
+ +@Html.Partial("_ChildPages") \ No newline at end of file diff --git a/docs/examples/pullrequest-id.md b/docs/examples/pullrequest-id.md new file mode 100644 index 0000000..843390d --- /dev/null +++ b/docs/examples/pullrequest-id.md @@ -0,0 +1,56 @@ +--- +Order: 10 +Title: Using with pull request id +Description: Example how to use the Cake.Issues.PullRequests.AzureDevOps addin with pull request id. +--- +This example shows how to write issues as comments to an Azure DevOps pull request while using pull request id. + +To determine the remote repository URL you need the [Cake.Git] addin: + +```csharp +#addin "Cake.Git" +``` + +To write issues as comments to Azure DevOps pull requests you need to import the core addin, +the core pull request addin, the Azure DevOps support including the Cake.AzureDevOps addin, and one or more issue providers, +in this example for JetBrains InspectCode: + +```csharp +#addin "Cake.Issues" +#addin "Cake.Issues.InspectCode" +#addin "Cake.Issues.PullRequests" +#addin "Cake.Issues.PullRequests.AzureDevOps" +#addin "Cake.AzureDevOps" +``` + +:::{.alert .alert-warning} +Please note that you always should pin addins to a specific version to make sure your builds are deterministic and +won't break due to updates to one of the addins. + +See [pinning addin versions](https://cakebuild.net/docs/tutorials/pinning-cake-version#pinning-addin-version) for details. +::: + +In the following task we'll first determine the remote repository URL and +with this information call the [AzureDevOpsPullRequests] alias, +which will authenticate through NTLM to an on-premise Azure DevOps Server instance: + +```csharp +Task("ReportIssuesToPullRequest").Does(() => +{ + var repoRootFolder = MakeAbsolute(Directory("./")); + var repoRemoteUrl = new Uri(currentBranch.Remotes.Single(x => x.Name == "origin").Url); + var pullRequestId = 123; + + ReportIssuesToPullRequest( + InspectCodeIssuesFromFilePath( + @"C:\build\inspectcode.log"), + AzureDevOpsPullRequests( + repoRemoteUrl, + pullRequestId, + AzureDevOpsAuthenticationNtlm()), + repoRootFolder); +}); +``` + +[AzureDevOpsPullRequests]: ../../../../api/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases/64912B0A +[Cake.Git]: https://www.nuget.org/packages/Cake.Git/ diff --git a/docs/examples/repository-information.md b/docs/examples/repository-information.md new file mode 100644 index 0000000..804ef7c --- /dev/null +++ b/docs/examples/repository-information.md @@ -0,0 +1,57 @@ +--- +Order: 20 +Title: Using with repository remote url and source branch name +Description: Example how to use the Cake.Issues.PullRequests.AzureDevOps addin with repository remote url and source branch name. +--- +This example shows how to write issues as comments to an Azure DevOps pull request while using repository information. + +To determine the remote repository URL and source branch of the pull request you need the [Cake.Git] addin: + +```csharp +#addin "Cake.Git" +``` + +To write issues as comments to Azure DevOps pull requests you need to import the core addin, +the core pull request addin, the Azure DevOps support including the Cake.AzureDevOps addin, and one or more issue providers, +in this example for JetBrains InspectCode: + +```csharp +#addin "Cake.Issues" +#addin "Cake.Issues.InspectCode" +#addin "Cake.Issues.PullRequests" +#addin "Cake.Issues.PullRequests.AzureDevOps" +#addin "Cake.AzureDevOps" +``` + +:::{.alert .alert-warning} +Please note that you always should pin addins to a specific version to make sure your builds are deterministic and +won't break due to updates to one of the addins. + +See [pinning addin versions](https://cakebuild.net/docs/tutorials/pinning-cake-version#pinning-addin-version) for details. +::: + +In the following task we'll first determine the remote repository URL and +source branch of the pull request and with this information call the [AzureDevOpsPullRequests] alias, +which will authenticate through NTLM to an on-premise Azure DevOps Server instance: + +```csharp +Task("ReportIssuesToPullRequest").Does(() => +{ + var repoRootFolder = MakeAbsolute(Directory("./")); + var currentBranch = GitBranchCurrent(repoRootFolder); + var repoRemoteUrl = new Uri(currentBranch.Remotes.Single(x => x.Name == "origin").Url); + var sourceBranchName = currentBranch.CanonicalName; + + ReportIssuesToPullRequest( + InspectCodeIssuesFromFilePath( + @"C:\build\inspectcode.log"), + AzureDevOpsPullRequests( + repoRemoteUrl, + sourceBranchName, + AzureDevOpsAuthenticationNtlm()), + repoRootFolder); +}); +``` + +[AzureDevOpsPullRequests]: ../../../../api/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases/8D75BECA +[Cake.Git]: https://www.nuget.org/packages/Cake.Git/ diff --git a/docs/features.md b/docs/features.md new file mode 100644 index 0000000..b3b4bc2 --- /dev/null +++ b/docs/features.md @@ -0,0 +1,48 @@ +--- +Order: 20 +Title: Features +Description: Features of the Cake.Issues.PullRequests.AzureDevOps addin. +--- +The [Cake.Issues.PullRequests.AzureDevOps addin] provides the following features. + +:::{.alert .alert-info} +There's a [demo repository] available which you can fork and to which you can create pull requests to test the integration functionality. +::: + +# Basic features + +* Writes issues as comments to [Azure DevOps] pull requests. +* Identification of pull requests through source branch or pull request ID. +* Comments written by the addin will be rendered with a specific icon corresponding to the state of the issue. +* Adds rule number and, if provided by the issue provider, link to the rule description to the comment. +* Support for issues messages formatted in Markdown format. + +# Supported capabilities + +The [Cake.Issues.PullRequests.AzureDevOps addin] supports all [Core features]. + +| | Capability | Remarks | +|--------------------------------------------------------------------|--------------------------------|--------------------------------| +| | Checking commit ID | | +| | Discussion threads | | +| | Filtering by modified files | | + +# Supported authentication methods + +| Azure DevOps Server | Azure DevOps Service | Authentication method | +|--------------------------------------------------------------------|--------------------------------------------------------------------|--------------------------------| +| | | NTLM | +| | | Basic authentication | +| | | Personal access token | +| | | OAuth | +| | | Azure Active Directory | + +For detailed instructions how to connect using the different methods see [Setup instructions]. + +![Cake.Issues.PullRequests.AzureDevOps](cake.issues.pullrequests.azuredevops.png "Cake.Issues.PullRequests.AzureDevOps") + +[demo repository]: https://dev.azure.com/pberger/Cake.Issues-Demo +[Cake.Issues.PullRequests.AzureDevOps addin]: https://www.nuget.org/packages/Cake.Issues.PullRequests.AzureDevOps +[Azure DevOps]: https://azure.microsoft.com/en-us/services/devops/ +[Core features]: ../../overview/features#supported-core-functionality +[Setup instructions]: setup diff --git a/docs/index.cshtml b/docs/index.cshtml new file mode 100644 index 0000000..fbf68af --- /dev/null +++ b/docs/index.cshtml @@ -0,0 +1,10 @@ +--- +Title: Azure DevOps +Description: Support for Azure DevOps. +--- +

+ Support for Azure DevOps is implemented in the + Cake.Issues.PullRequests.AzureDevOps addin. +

+ +@Html.Partial("_ChildPages") \ No newline at end of file diff --git a/docs/requirements.md b/docs/requirements.md new file mode 100644 index 0000000..9c24511 --- /dev/null +++ b/docs/requirements.md @@ -0,0 +1,9 @@ +--- +Order: 10 +Title: Requirements +Description: Requirements for the Cake.Issues.PullRequests.AzureDevOps addin. +--- +The requirements for using the [Cake.Issues.PullRequests.AzureDevOps addin] are listed in the [release notes] for any specific version. + +[Cake.Issues.PullRequests.AzureDevOps addin]: https://www.nuget.org/packages/Cake.Issues.PullRequests.AzureDevOps +[release notes]: release-notes diff --git a/docs/setup.md b/docs/setup.md new file mode 100644 index 0000000..ac9f128 --- /dev/null +++ b/docs/setup.md @@ -0,0 +1,78 @@ +--- +Order: 30 +Title: Setup +Description: Instructions how to setup the Cake.Issues.PullRequests.AzureDevOps addin. +--- +This page describes the different ways how the [Cake.Issues.PullRequests.AzureDevOps addin] can be setup. + +# NTLM authentication + +:::{.alert .alert-info} +NTLM authentication is only available for on-premise Azure DevOps Server. +::: + +To authenticate with NTLM you can use the [AzureDevOpsAuthenticationNtlm] alias from the [Cake.AzureDevOps addin]. + +The user needs to have `Contribute to pull requests` permission for the specific repository to +allow [Cake.Issues.PullRequests.AzureDevOps addin] to post issues as comments to pull requests. + +# Basic authentication + +:::{.alert .alert-info} +Basic authentication is only available for on-premise Azure DevOps Server. +::: + +To authenticate with basic authentication you can use the [AzureDevOpsAuthenticationBasic] alias from the [Cake.AzureDevOps addin] and +need to [Configure AzureDevOps Server to use Basic Authentication]. + +The user needs to have `Contribute to pull requests` permission for the specific repository to +allow [Cake.Issues.PullRequests.AzureDevOps addin] to post issues as comments to pull requests. + +# Personal access token + +To authenticate with an personal access token you can use the [AzureDevOpsAuthenticationPersonalAccessToken] alias from the [Cake.AzureDevOps addin]. + +If you want to use the [Cake.Issues.PullRequests.AzureDevOps addin] with an personal access token see +[Authenticate access with personal access tokens for Azure DevOps] for instructions how to create +a personal access token. + +The access token needs to have the scope `Code (read and write)` set and the user needs to have `Contribute to pull requests` +permission for the specific repository to allow [Cake.Issues.PullRequests.AzureDevOps addin] to post issues as comments to pull requests. + +# OAuth authentication from Azure Pipelines + +:::{.alert .alert-info} +OAuth authentication is only available for Azure DevOps Service. +::: + +If you want to use the [Cake.Issues.PullRequests.AzureDevOps addin] from an Azure Pipelines you can authenticate using the +OAuth token provided to the build. +For this you need to enable the [Allow scripts to access the OAuth token] option on the build definition. + +To authenticate you can use the [AzureDevOpsAuthenticationOAuth] alias from the [Cake.AzureDevOps addin]. + +The user under which the build runs, named ` Build Service ()` (e.g. `Cake.Issues-Demo Build Service (cake-contrib)`), +needs to have `Contribute to pull requests` permission for the specific repository to allow [Cake.Issues.PullRequests.AzureDevOps addin] +to post issues as comments to pull requests. + +# Azure Active Directory + +:::{.alert .alert-info} +OAuth authentication is only available for Azure DevOps Service. +::: + +To authenticate with Azure Active Directory you can use the [AzureDevOpsAuthenticationAzureActiveDirectory] alias from the [Cake.AzureDevOps addin]. + +The user needs to have `Contribute to pull requests` permission for the specific repository to +allow [Cake.Issues.PullRequests.AzureDevOps addin] to post issues as comments to pull requests. + +[Cake.Issues.PullRequests.AzureDevOps addin]: https://www.nuget.org/packages/Cake.Issues.PullRequests.AzureDevOps +[Cake.AzureDevOps addin]: https://www.nuget.org/packages/Cake.AzureDevOps +[Configure TFS to use Basic Authentication]: https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/auth/tfs-basic-auth#configure-tfs-to-use-basic-authentication +[Authenticate access with personal access tokens for Azure DevOps]: https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate +[Allow scripts to access the OAuth token]: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/options#allow-scripts-to-access-the-oauth-token +[AzureDevOpsAuthenticationNtlm]: https://cakebuild.net/api/Cake.AzureDevOps/AzureDevOpsAliases/F2A040B7 +[AzureDevOpsAuthenticationBasic]: https://cakebuild.net/api/Cake.AzureDevOps/AzureDevOpsAliases/7CD679FF +[AzureDevOpsAuthenticationPersonalAccessToken]: https://cakebuild.net/api/Cake.AzureDevOps/AzureDevOpsAliases/F4DCC101 +[AzureDevOpsAuthenticationOAuth]: https://cakebuild.net/api/Cake.AzureDevOps/AzureDevOpsAliases/988E9C28 +[AzureDevOpsAuthenticationAzureActiveDirectory]: https://cakebuild.net/api/Cake.AzureDevOps/AzureDevOpsAliases/0B9F5DF6 diff --git a/setup.cake b/recipe.cake similarity index 70% rename from setup.cake rename to recipe.cake index 13a5083..2d2228b 100644 --- a/setup.cake +++ b/recipe.cake @@ -6,10 +6,12 @@ BuildParameters.SetParameters( context: Context, buildSystem: BuildSystem, sourceDirectoryPath: "./src", - title: "Cake.Issues.PullRequests.Tfs", + title: "Cake.Issues.PullRequests.AzureDevOps", repositoryOwner: "cake-contrib", - repositoryName: "Cake.Issues.PullRequests.Tfs", + repositoryName: "Cake.Issues.PullRequests.AzureDevOps", appVeyorAccountName: "cakecontrib", + shouldGenerateDocumentation: false, + shouldRunGitVersion: true, shouldRunCodecov: false, shouldRunDotNetCorePack: true); @@ -17,8 +19,8 @@ BuildParameters.PrintParameters(Context); ToolSettings.SetToolSettings( context: Context, - dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/*.cs" }, - testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]* -[Cake.Issues.Testing]* -[Cake.Issues.PullRequests]* -[Cake.Tfs]* -[Shouldly]*", + dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/*.cs" }, + testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]* -[Cake.Issues.Testing]* -[Cake.Issues.PullRequests]* -[Cake.AzureDevOps]* -[Shouldly]*", testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*", testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs"); diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests.ruleset b/src/Cake.Issues.PullRequests.AzureDevOps.Tests.ruleset similarity index 53% rename from src/Cake.Issues.PullRequests.Tfs.Tests.ruleset rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests.ruleset index dccc7b5..ca8c3a4 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests.ruleset +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests.ruleset @@ -1,6 +1,6 @@  - - + + diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/TfsPullRequestSystemSettingsTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/AzureDevOpsPullRequestSystemSettingsTests.cs similarity index 64% rename from src/Cake.Issues.PullRequests.Tfs.Tests/TfsPullRequestSystemSettingsTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/AzureDevOpsPullRequestSystemSettingsTests.cs index a622f2b..e8b40d1 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/TfsPullRequestSystemSettingsTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/AzureDevOpsPullRequestSystemSettingsTests.cs @@ -1,10 +1,10 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests +namespace Cake.Issues.PullRequests.AzureDevOps.Tests { using System; using Cake.Issues.Testing; using Xunit; - public sealed class TfsPullRequestSystemSettingsTests + public sealed class AzureDevOpsPullRequestSystemSettingsTests { public sealed class TheCtor { @@ -12,7 +12,7 @@ public sealed class TheCtor public void Should_Throw_If_RepositoryUrl_For_SourceRefName_Is_Null() { // Given / When - var result = Record.Exception(() => new TfsPullRequestSystemSettings(null, "foo", null)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystemSettings(null, "foo", null)); // Then result.IsArgumentNullException("repositoryUrl"); @@ -22,7 +22,7 @@ public void Should_Throw_If_RepositoryUrl_For_SourceRefName_Is_Null() public void Should_Throw_If_SourceRefName_Is_Null() { // Given / When - var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), null, null)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystemSettings(new Uri("http://example.com"), null, null)); // Then result.IsArgumentNullException("sourceRefName"); @@ -32,7 +32,7 @@ public void Should_Throw_If_SourceRefName_Is_Null() public void Should_Throw_If_SourceRefName_Is_Empty() { // Given / When - var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), string.Empty, null)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystemSettings(new Uri("http://example.com"), string.Empty, null)); // Then result.IsArgumentOutOfRangeException("sourceRefName"); @@ -42,7 +42,7 @@ public void Should_Throw_If_SourceRefName_Is_Empty() public void Should_Throw_If_SourceRefName_Is_WhiteSpace() { // Given / When - var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), " ", null)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystemSettings(new Uri("http://example.com"), " ", null)); // Then result.IsArgumentOutOfRangeException("sourceRefName"); @@ -52,7 +52,7 @@ public void Should_Throw_If_SourceRefName_Is_WhiteSpace() public void Should_Throw_If_RepositoryUrl_For_PullRequestId_Is_Null() { // Given / When - var result = Record.Exception(() => new TfsPullRequestSystemSettings(null, 0, null)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystemSettings(null, 0, null)); // Then result.IsArgumentNullException("repositoryUrl"); @@ -62,7 +62,7 @@ public void Should_Throw_If_RepositoryUrl_For_PullRequestId_Is_Null() public void Should_Throw_If_Credentials_For_PullRequestId_Are_Null() { // Given / When - var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), 42, null)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystemSettings(new Uri("http://example.com"), 42, null)); // Then result.IsArgumentNullException("credentials"); @@ -72,7 +72,7 @@ public void Should_Throw_If_Credentials_For_PullRequestId_Are_Null() public void Should_Throw_If_Credentials_For_SourceBranch_Are_Null() { // Given / When - var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), "feature/foo", null)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystemSettings(new Uri("http://example.com"), "feature/foo", null)); // Then result.IsArgumentNullException("credentials"); diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/TfsPullRequestSystemTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/AzureDevOpsPullRequestSystemTests.cs similarity index 60% rename from src/Cake.Issues.PullRequests.Tfs.Tests/TfsPullRequestSystemTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/AzureDevOpsPullRequestSystemTests.cs index d73c253..9e68d3a 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/TfsPullRequestSystemTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/AzureDevOpsPullRequestSystemTests.cs @@ -1,13 +1,13 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests +namespace Cake.Issues.PullRequests.AzureDevOps.Tests { using System; + using Cake.AzureDevOps.Authentication; using Cake.Core.Diagnostics; using Cake.Issues.Testing; using Cake.Testing; - using Cake.Tfs.Authentication; using Xunit; - public sealed class TfsPullRequestSystemTests + public sealed class AzureDevOpsPullRequestSystemTests { public sealed class TheCtor { @@ -17,13 +17,13 @@ public void Should_Throw_If_Log_Is_Null() // Given ICakeLog log = null; var settings = - new TfsPullRequestSystemSettings( + new AzureDevOpsPullRequestSystemSettings( new Uri("https://google.com"), 123, - new TfsNtlmCredentials()); + new AzureDevOpsNtlmCredentials()); // When - var result = Record.Exception(() => new TfsPullRequestSystem(log, settings)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystem(log, settings)); // Then result.IsArgumentNullException("log"); @@ -34,10 +34,10 @@ public void Should_Throw_If_Settings_Are_Null() { // Given var log = new FakeLog(); - TfsPullRequestSystemSettings settings = null; + AzureDevOpsPullRequestSystemSettings settings = null; // When - var result = Record.Exception(() => new TfsPullRequestSystem(log, settings)); + var result = Record.Exception(() => new AzureDevOpsPullRequestSystem(log, settings)); // Then result.IsArgumentNullException("settings"); diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Cake.Issues.PullRequests.Tfs.Tests.csproj b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Cake.Issues.PullRequests.AzureDevOps.Tests.csproj similarity index 62% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Cake.Issues.PullRequests.Tfs.Tests.csproj rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Cake.Issues.PullRequests.AzureDevOps.Tests.csproj index 310f480..7a610de 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/Cake.Issues.PullRequests.Tfs.Tests.csproj +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Cake.Issues.PullRequests.AzureDevOps.Tests.csproj @@ -3,24 +3,24 @@ netcoreapp2.0 false - Cake.Issues.PullRequests.Tfs + Cake.Issues.PullRequests.AzureDevOps Copyright © BBT Software AG and contributors - Tests for the Cake.Issues.PullRequests.Tfs addin + Tests for the Cake.Issues.PullRequests.AzureDevOps addin BBT Software AG and contributors - ..\Cake.Issues.PullRequests.Tfs.Tests.ruleset + ..\Cake.Issues.PullRequests.AzureDevOps.Tests.ruleset latest - - - + + + - + @@ -29,7 +29,7 @@ - + \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsFilteringByModifiedFilesCapabilityTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsCheckingCommitIdCapabilityTests.cs similarity index 56% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsFilteringByModifiedFilesCapabilityTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsCheckingCommitIdCapabilityTests.cs index ed988f4..f433063 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsFilteringByModifiedFilesCapabilityTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsCheckingCommitIdCapabilityTests.cs @@ -1,13 +1,13 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Tests.Capabilities { using Cake.Core.Diagnostics; - using Cake.Issues.PullRequests.Tfs.Capabilities; + using Cake.Issues.PullRequests.AzureDevOps.Capabilities; using Cake.Issues.Testing; using Cake.Testing; using NSubstitute; using Xunit; - public sealed class TfsFilteringByModifiedFilesCapabilityTests + public sealed class AzureDevOpsCheckingCommitIdCapabilityTests { public sealed class TheCtor { @@ -16,10 +16,10 @@ public void Should_Throw_If_Log_Is_Null() { // Given ICakeLog log = null; - var pullRequestSystem = Substitute.For(); + var pullRequestSystem = Substitute.For(); // When - var result = Record.Exception(() => new TfsFilteringByModifiedFilesCapability(log, pullRequestSystem)); + var result = Record.Exception(() => new AzureDevOpsCheckingCommitIdCapability(log, pullRequestSystem)); // Then result.IsArgumentNullException("log"); @@ -30,10 +30,10 @@ public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given var log = new FakeLog(); - TfsPullRequestSystem pullRequestSystem = null; + AzureDevOpsPullRequestSystem pullRequestSystem = null; // When - var result = Record.Exception(() => new TfsFilteringByModifiedFilesCapability(log, pullRequestSystem)); + var result = Record.Exception(() => new AzureDevOpsCheckingCommitIdCapability(log, pullRequestSystem)); // Then result.IsArgumentNullException("pullRequestSystem"); diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsCheckingCommitIdCapabilityTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsDiscussionThreadsCapabilityTests.cs similarity index 56% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsCheckingCommitIdCapabilityTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsDiscussionThreadsCapabilityTests.cs index ee38adb..2a04fd4 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsCheckingCommitIdCapabilityTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsDiscussionThreadsCapabilityTests.cs @@ -1,13 +1,13 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Tests.Capabilities { using Cake.Core.Diagnostics; - using Cake.Issues.PullRequests.Tfs.Capabilities; + using Cake.Issues.PullRequests.AzureDevOps.Capabilities; using Cake.Issues.Testing; using Cake.Testing; using NSubstitute; using Xunit; - public sealed class TfsCheckingCommitIdCapabilityTests + public sealed class AzureDevOpsDiscussionThreadsCapabilityTests { public sealed class TheCtor { @@ -16,10 +16,10 @@ public void Should_Throw_If_Log_Is_Null() { // Given ICakeLog log = null; - var pullRequestSystem = Substitute.For(); + var pullRequestSystem = Substitute.For(); // When - var result = Record.Exception(() => new TfsCheckingCommitIdCapability(log, pullRequestSystem)); + var result = Record.Exception(() => new AzureDevOpsDiscussionThreadsCapability(log, pullRequestSystem)); // Then result.IsArgumentNullException("log"); @@ -30,10 +30,10 @@ public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given var log = new FakeLog(); - TfsPullRequestSystem pullRequestSystem = null; + AzureDevOpsPullRequestSystem pullRequestSystem = null; // When - var result = Record.Exception(() => new TfsCheckingCommitIdCapability(log, pullRequestSystem)); + var result = Record.Exception(() => new AzureDevOpsDiscussionThreadsCapability(log, pullRequestSystem)); // Then result.IsArgumentNullException("pullRequestSystem"); diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsDiscussionThreadsCapabilityTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsFilteringByModifiedFilesCapabilityTests.cs similarity index 55% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsDiscussionThreadsCapabilityTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsFilteringByModifiedFilesCapabilityTests.cs index f79bb18..f6172e6 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/TfsDiscussionThreadsCapabilityTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/AzureDevOpsFilteringByModifiedFilesCapabilityTests.cs @@ -1,13 +1,13 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Tests.Capabilities { using Cake.Core.Diagnostics; - using Cake.Issues.PullRequests.Tfs.Capabilities; + using Cake.Issues.PullRequests.AzureDevOps.Capabilities; using Cake.Issues.Testing; using Cake.Testing; using NSubstitute; using Xunit; - public sealed class TfsDiscussionThreadsCapabilityTests + public sealed class AzureDevOpsFilteringByModifiedFilesCapabilityTests { public sealed class TheCtor { @@ -16,10 +16,10 @@ public void Should_Throw_If_Log_Is_Null() { // Given ICakeLog log = null; - var pullRequestSystem = Substitute.For(); + var pullRequestSystem = Substitute.For(); // When - var result = Record.Exception(() => new TfsDiscussionThreadsCapability(log, pullRequestSystem)); + var result = Record.Exception(() => new AzureDevOpsFilteringByModifiedFilesCapability(log, pullRequestSystem)); // Then result.IsArgumentNullException("log"); @@ -30,10 +30,10 @@ public void Should_Throw_If_PullRequestSystem_Is_Null() { // Given var log = new FakeLog(); - TfsPullRequestSystem pullRequestSystem = null; + AzureDevOpsPullRequestSystem pullRequestSystem = null; // When - var result = Record.Exception(() => new TfsDiscussionThreadsCapability(log, pullRequestSystem)); + var result = Record.Exception(() => new AzureDevOpsFilteringByModifiedFilesCapability(log, pullRequestSystem)); // Then result.IsArgumentNullException("pullRequestSystem"); diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/CommentExtensionsTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/CommentExtensionsTests.cs similarity index 82% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/CommentExtensionsTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/CommentExtensionsTests.cs index d4672d9..d526150 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/CommentExtensionsTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/CommentExtensionsTests.cs @@ -1,8 +1,8 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Tests.Capabilities { - using Cake.Issues.PullRequests.Tfs.Capabilities; + using Cake.AzureDevOps.PullRequest.CommentThread; + using Cake.Issues.PullRequests.AzureDevOps.Capabilities; using Cake.Issues.Testing; - using Cake.Tfs.PullRequest.CommentThread; using Shouldly; using Xunit; @@ -14,7 +14,7 @@ public sealed class TheToPullRequestDiscussionCommentExtension public void Should_Throw_If_Comment_Is_Null() { // Given - TfsComment comment = null; + AzureDevOpsComment comment = null; // When var result = Record.Exception(() => comment.ToPullRequestDiscussionComment()); @@ -29,7 +29,7 @@ public void Should_Set_Correct_Content() // Given var content = "foo"; var comment = - new TfsComment + new AzureDevOpsComment { Content = content, }; @@ -48,7 +48,7 @@ public void Should_Set_Correct_IsDeleted(bool isDeleted) { // Given var comment = - new TfsComment + new AzureDevOpsComment { IsDeleted = isDeleted, }; diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/CommentThreadStatusExtensionsTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/CommentThreadStatusExtensionsTests.cs similarity index 66% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/CommentThreadStatusExtensionsTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/CommentThreadStatusExtensionsTests.cs index 50ac583..b9ad454 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/CommentThreadStatusExtensionsTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/CommentThreadStatusExtensionsTests.cs @@ -1,7 +1,7 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Tests.Capabilities { - using Cake.Issues.PullRequests.Tfs.Capabilities; - using Cake.Tfs.PullRequest.CommentThread; + using Cake.AzureDevOps.PullRequest.CommentThread; + using Cake.Issues.PullRequests.AzureDevOps.Capabilities; using Shouldly; using Xunit; @@ -11,28 +11,28 @@ public sealed class TheToPullRequestDiscussionStatusExtension { [Theory] [InlineData( - TfsCommentThreadStatus.Unknown, + AzureDevOpsCommentThreadStatus.Unknown, PullRequestDiscussionStatus.Unknown)] [InlineData( - TfsCommentThreadStatus.Active, + AzureDevOpsCommentThreadStatus.Active, PullRequestDiscussionStatus.Active)] [InlineData( - TfsCommentThreadStatus.Pending, + AzureDevOpsCommentThreadStatus.Pending, PullRequestDiscussionStatus.Active)] [InlineData( - TfsCommentThreadStatus.Fixed, + AzureDevOpsCommentThreadStatus.Fixed, PullRequestDiscussionStatus.Resolved)] [InlineData( - TfsCommentThreadStatus.WontFix, + AzureDevOpsCommentThreadStatus.WontFix, PullRequestDiscussionStatus.Resolved)] [InlineData( - TfsCommentThreadStatus.Closed, + AzureDevOpsCommentThreadStatus.Closed, PullRequestDiscussionStatus.Resolved)] [InlineData( - TfsCommentThreadStatus.ByDesign, + AzureDevOpsCommentThreadStatus.ByDesign, PullRequestDiscussionStatus.Resolved)] public void Should_Return_Correct_Value( - TfsCommentThreadStatus status, + AzureDevOpsCommentThreadStatus status, PullRequestDiscussionStatus expectedResult) { // Given @@ -49,28 +49,28 @@ public sealed class TheToPullRequestDiscussionResolutionExtension { [Theory] [InlineData( - TfsCommentThreadStatus.Unknown, + AzureDevOpsCommentThreadStatus.Unknown, PullRequestDiscussionResolution.Unknown)] [InlineData( - TfsCommentThreadStatus.Active, + AzureDevOpsCommentThreadStatus.Active, PullRequestDiscussionResolution.Unknown)] [InlineData( - TfsCommentThreadStatus.Pending, + AzureDevOpsCommentThreadStatus.Pending, PullRequestDiscussionResolution.Unknown)] [InlineData( - TfsCommentThreadStatus.Fixed, + AzureDevOpsCommentThreadStatus.Fixed, PullRequestDiscussionResolution.Resolved)] [InlineData( - TfsCommentThreadStatus.WontFix, + AzureDevOpsCommentThreadStatus.WontFix, PullRequestDiscussionResolution.WontFix)] [InlineData( - TfsCommentThreadStatus.Closed, + AzureDevOpsCommentThreadStatus.Closed, PullRequestDiscussionResolution.Resolved)] [InlineData( - TfsCommentThreadStatus.ByDesign, + AzureDevOpsCommentThreadStatus.ByDesign, PullRequestDiscussionResolution.Resolved)] public void Should_Return_Correct_Value( - TfsCommentThreadStatus status, + AzureDevOpsCommentThreadStatus status, PullRequestDiscussionResolution expectedResult) { // Given diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/GitPullRequestCommentThreadExtensionsTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/GitPullRequestCommentThreadExtensionsTests.cs similarity index 75% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/GitPullRequestCommentThreadExtensionsTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/GitPullRequestCommentThreadExtensionsTests.cs index d272204..9976b7f 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/Capabilities/GitPullRequestCommentThreadExtensionsTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Capabilities/GitPullRequestCommentThreadExtensionsTests.cs @@ -1,10 +1,10 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Tests.Capabilities { using System.Collections.Generic; using System.Linq; - using Cake.Issues.PullRequests.Tfs.Capabilities; + using Cake.AzureDevOps.PullRequest.CommentThread; + using Cake.Issues.PullRequests.AzureDevOps.Capabilities; using Cake.Issues.Testing; - using Cake.Tfs.PullRequest.CommentThread; using Shouldly; using Xunit; @@ -16,7 +16,7 @@ public sealed class TheToPullRequestDiscussionThreadExtension public void Should_Throw_If_Thread_Is_Null() { // Given - TfsPullRequestCommentThread thread = null; + AzureDevOpsPullRequestCommentThread thread = null; // When var result = Record.Exception(() => thread.ToPullRequestDiscussionThread()); @@ -30,10 +30,10 @@ public void Should_Throw_If_Comments_Are_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", Comments = null, Properties = new Dictionary(), @@ -51,12 +51,12 @@ public void Should_Not_Throw_If_Properties_Are_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = null, }; @@ -72,15 +72,15 @@ public void Should_Set_Correct_Id() { // Given var id = 123; - var status = TfsCommentThreadStatus.Active; + var status = AzureDevOpsCommentThreadStatus.Active; var filePath = "/foo.cs"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = id, Status = status, FilePath = filePath, - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; @@ -93,40 +93,40 @@ public void Should_Set_Correct_Id() [Theory] [InlineData( - TfsCommentThreadStatus.Unknown, + AzureDevOpsCommentThreadStatus.Unknown, PullRequestDiscussionStatus.Unknown)] [InlineData( - TfsCommentThreadStatus.Active, + AzureDevOpsCommentThreadStatus.Active, PullRequestDiscussionStatus.Active)] [InlineData( - TfsCommentThreadStatus.Pending, + AzureDevOpsCommentThreadStatus.Pending, PullRequestDiscussionStatus.Active)] [InlineData( - TfsCommentThreadStatus.Fixed, + AzureDevOpsCommentThreadStatus.Fixed, PullRequestDiscussionStatus.Resolved)] [InlineData( - TfsCommentThreadStatus.WontFix, + AzureDevOpsCommentThreadStatus.WontFix, PullRequestDiscussionStatus.Resolved)] [InlineData( - TfsCommentThreadStatus.Closed, + AzureDevOpsCommentThreadStatus.Closed, PullRequestDiscussionStatus.Resolved)] [InlineData( - TfsCommentThreadStatus.ByDesign, + AzureDevOpsCommentThreadStatus.ByDesign, PullRequestDiscussionStatus.Resolved)] public void Should_Set_Correct_Status( - TfsCommentThreadStatus status, + AzureDevOpsCommentThreadStatus status, PullRequestDiscussionStatus expectedResult) { // Given var id = 123; var filePath = "/foo.cs"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = id, Status = status, FilePath = filePath, - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; @@ -143,14 +143,14 @@ public void Should_Set_Correct_FilePath(string filePath, string expectedResult) { // Given var id = 123; - var status = TfsCommentThreadStatus.Active; + var status = AzureDevOpsCommentThreadStatus.Active; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = id, Status = status, FilePath = filePath, - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; @@ -166,11 +166,11 @@ public void Should_Set_Correct_FilePath_If_ThreadContext_Is_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, - Comments = new List(), + Status = AzureDevOpsCommentThreadStatus.Active, + Comments = new List(), Properties = new Dictionary(), }; @@ -186,19 +186,19 @@ public void Should_Set_Correct_Comments() { // Given var id = 123; - var status = TfsCommentThreadStatus.Active; + var status = AzureDevOpsCommentThreadStatus.Active; var filePath = "/foo.cs"; var commentContent = "foo"; var commentIsDeleted = false; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = id, Status = status, FilePath = filePath, - Comments = new List + Comments = new List { - new TfsComment() + new AzureDevOpsComment() { Content = commentContent, IsDeleted = commentIsDeleted, @@ -221,16 +221,16 @@ public void Should_Set_Correct_CommentSource() { // Given var id = 123; - var status = TfsCommentThreadStatus.Active; + var status = AzureDevOpsCommentThreadStatus.Active; var filePath = "/foo.cs"; var commentSource = "foo"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = id, Status = status, FilePath = filePath, - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; thread.SetCommentSource(commentSource); @@ -244,40 +244,40 @@ public void Should_Set_Correct_CommentSource() [Theory] [InlineData( - TfsCommentThreadStatus.Unknown, + AzureDevOpsCommentThreadStatus.Unknown, PullRequestDiscussionResolution.Unknown)] [InlineData( - TfsCommentThreadStatus.Active, + AzureDevOpsCommentThreadStatus.Active, PullRequestDiscussionResolution.Unknown)] [InlineData( - TfsCommentThreadStatus.Pending, + AzureDevOpsCommentThreadStatus.Pending, PullRequestDiscussionResolution.Unknown)] [InlineData( - TfsCommentThreadStatus.Fixed, + AzureDevOpsCommentThreadStatus.Fixed, PullRequestDiscussionResolution.Resolved)] [InlineData( - TfsCommentThreadStatus.WontFix, + AzureDevOpsCommentThreadStatus.WontFix, PullRequestDiscussionResolution.WontFix)] [InlineData( - TfsCommentThreadStatus.Closed, + AzureDevOpsCommentThreadStatus.Closed, PullRequestDiscussionResolution.Resolved)] [InlineData( - TfsCommentThreadStatus.ByDesign, + AzureDevOpsCommentThreadStatus.ByDesign, PullRequestDiscussionResolution.Resolved)] public void Should_Set_Correct_Resolution( - TfsCommentThreadStatus status, + AzureDevOpsCommentThreadStatus status, PullRequestDiscussionResolution expectedResult) { // Given var id = 123; var filePath = "/foo.cs"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = id, Status = status, FilePath = filePath, - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; @@ -295,7 +295,7 @@ public sealed class TheGetCommentSourceExtension public void Should_Throw_If_Thread_Is_Null() { // Given - TfsPullRequestCommentThread thread = null; + AzureDevOpsPullRequestCommentThread thread = null; // When var result = Record.Exception(() => thread.GetCommentSource()); @@ -309,12 +309,12 @@ public void Should_Not_Throw_If_Properties_Are_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = null, }; @@ -331,12 +331,12 @@ public void Should_Return_Comment_Source() // Given var commentSource = "foo"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; thread.SetCommentSource(commentSource); @@ -355,7 +355,7 @@ public sealed class TheSetCommentSourceExtension public void Should_Throw_If_Thread_Is_Null() { // Given - TfsPullRequestCommentThread thread = null; + AzureDevOpsPullRequestCommentThread thread = null; var value = "foo"; // When @@ -370,12 +370,12 @@ public void Should_Throw_If_Properties_Are_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = null, }; var value = "foo"; @@ -393,12 +393,12 @@ public void Should_Set_Comment_Source() // Given var commentSource = "foo"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; @@ -416,7 +416,7 @@ public sealed class TheIsCommentSourceExtension public void Should_Throw_If_Thread_Is_Null() { // Given - TfsPullRequestCommentThread thread = null; + AzureDevOpsPullRequestCommentThread thread = null; var value = "foo"; // When @@ -431,12 +431,12 @@ public void Should_Not_Throw_If_Properties_Are_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = null, }; var value = "foo"; @@ -454,12 +454,12 @@ public void Should_Return_True_For_Existing_Comment_Source() // Given var commentSource = "foo"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; thread.SetCommentSource(commentSource); @@ -476,12 +476,12 @@ public void Should_Return_False_For_Non_Existing_Comment_Source() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; thread.SetCommentSource("foo"); @@ -500,7 +500,7 @@ public sealed class TheGetIssueMessageExtension public void Should_Throw_If_Thread_Is_Null() { // Given - TfsPullRequestCommentThread thread = null; + AzureDevOpsPullRequestCommentThread thread = null; // When var result = Record.Exception(() => thread.GetIssueMessage()); @@ -514,12 +514,12 @@ public void Should_Not_Throw_If_Properties_Are_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = null, }; @@ -536,12 +536,12 @@ public void Should_Return_Message() // Given var message = "foo"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; thread.SetIssueMessage(message); @@ -560,7 +560,7 @@ public sealed class TheSetIssueMessageExtension public void Should_Throw_If_Thread_Is_Null() { // Given - TfsPullRequestCommentThread thread = null; + AzureDevOpsPullRequestCommentThread thread = null; var value = "foo"; // When @@ -575,12 +575,12 @@ public void Should_Throw_If_Properties_Are_Null() { // Given var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = null, }; var value = "foo"; @@ -598,12 +598,12 @@ public void Should_Return_Message() // Given var message = "foo"; var thread = - new TfsPullRequestCommentThread + new AzureDevOpsPullRequestCommentThread { Id = 123, - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, FilePath = "/foo.cs", - Comments = new List(), + Comments = new List(), Properties = new Dictionary(), }; diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/ContentProviderTests.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/ContentProviderTests.cs similarity index 97% rename from src/Cake.Issues.PullRequests.Tfs.Tests/ContentProviderTests.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/ContentProviderTests.cs index e58b2e1..d727869 100644 --- a/src/Cake.Issues.PullRequests.Tfs.Tests/ContentProviderTests.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/ContentProviderTests.cs @@ -1,4 +1,4 @@ -namespace Cake.Issues.PullRequests.Tfs.Tests +namespace Cake.Issues.PullRequests.AzureDevOps.Tests { using System; using Shouldly; diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/Properties/AssemblyInfo.cs b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/Properties/AssemblyInfo.cs similarity index 100% rename from src/Cake.Issues.PullRequests.Tfs.Tests/Properties/AssemblyInfo.cs rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/Properties/AssemblyInfo.cs diff --git a/src/Cake.Issues.PullRequests.Tfs.Tests/app.config b/src/Cake.Issues.PullRequests.AzureDevOps.Tests/app.config similarity index 100% rename from src/Cake.Issues.PullRequests.Tfs.Tests/app.config rename to src/Cake.Issues.PullRequests.AzureDevOps.Tests/app.config diff --git a/src/Cake.Issues.PullRequests.Tfs.ruleset b/src/Cake.Issues.PullRequests.AzureDevOps.ruleset similarity index 98% rename from src/Cake.Issues.PullRequests.Tfs.ruleset rename to src/Cake.Issues.PullRequests.AzureDevOps.ruleset index f3985ae..66c8bf4 100644 --- a/src/Cake.Issues.PullRequests.Tfs.ruleset +++ b/src/Cake.Issues.PullRequests.AzureDevOps.ruleset @@ -1,5 +1,5 @@  - + diff --git a/src/Cake.Issues.PullRequests.Tfs.sln b/src/Cake.Issues.PullRequests.AzureDevOps.sln similarity index 81% rename from src/Cake.Issues.PullRequests.Tfs.sln rename to src/Cake.Issues.PullRequests.AzureDevOps.sln index bd4878a..34a4c57 100644 --- a/src/Cake.Issues.PullRequests.Tfs.sln +++ b/src/Cake.Issues.PullRequests.AzureDevOps.sln @@ -3,13 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.28922.388 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Issues.PullRequests.Tfs", "Cake.Issues.PullRequests.Tfs\Cake.Issues.PullRequests.Tfs.csproj", "{1D046545-035B-4D7E-98C8-8AE6F5D0D289}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Issues.PullRequests.AzureDevOps", "Cake.Issues.PullRequests.AzureDevOps\Cake.Issues.PullRequests.AzureDevOps.csproj", "{1D046545-035B-4D7E-98C8-8AE6F5D0D289}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Issues.PullRequests.Tfs.Tests", "Cake.Issues.PullRequests.Tfs.Tests\Cake.Issues.PullRequests.Tfs.Tests.csproj", "{E938CD33-F1C7-45ED-A12C-7F18934AD131}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Issues.PullRequests.AzureDevOps.Tests", "Cake.Issues.PullRequests.AzureDevOps.Tests\Cake.Issues.PullRequests.AzureDevOps.Tests.csproj", "{E938CD33-F1C7-45ED-A12C-7F18934AD131}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{AAD732D5-4A2D-4A67-B571-7CD931983393}" ProjectSection(SolutionItems) = preProject - ..\setup.cake = ..\setup.cake + ..\recipe.cake = ..\recipe.cake EndProjectSection EndProject Global diff --git a/src/Cake.Issues.PullRequests.Tfs.sln.DotSettings b/src/Cake.Issues.PullRequests.AzureDevOps.sln.DotSettings similarity index 100% rename from src/Cake.Issues.PullRequests.Tfs.sln.DotSettings rename to src/Cake.Issues.PullRequests.AzureDevOps.sln.DotSettings diff --git a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystem.cs b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystem.cs similarity index 73% rename from src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystem.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystem.cs index 9b71134..365a417 100644 --- a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystem.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystem.cs @@ -1,31 +1,30 @@ -namespace Cake.Issues.PullRequests.Tfs +namespace Cake.Issues.PullRequests.AzureDevOps { using System; using System.Collections.Generic; using System.Globalization; using System.Linq; - using System.Threading; + using Cake.AzureDevOps.PullRequest; + using Cake.AzureDevOps.PullRequest.CommentThread; using Cake.Core.Diagnostics; using Cake.Core.IO; - using Cake.Issues.PullRequests.Tfs.Capabilities; - using Cake.Tfs.PullRequest; - using Cake.Tfs.PullRequest.CommentThread; + using Cake.Issues.PullRequests.AzureDevOps.Capabilities; /// - /// Class for writing issues to Team Foundation Server or Azure DevOps pull requests. + /// Class for writing issues to Azure DevOps pull requests. /// - internal sealed class TfsPullRequestSystem : BasePullRequestSystem, ITfsPullRequestSystem + internal sealed class AzureDevOpsPullRequestSystem : BasePullRequestSystem, IAzureDevOpsPullRequestSystem { - private readonly TfsPullRequestSystemSettings settings; - private readonly TfsPullRequest tfsPullRequest; + private readonly AzureDevOpsPullRequestSystemSettings settings; + private readonly AzureDevOpsPullRequest azureDevOpsPullRequest; /// - /// Initializes a new instance of the class. - /// Connects to the TFS server using NTLM authentication. + /// Initializes a new instance of the class. + /// Connects to the Azure DevOps server using NTLM authentication. /// /// The Cake log context. - /// Settings for accessing TFS. - public TfsPullRequestSystem(ICakeLog log, TfsPullRequestSystemSettings settings) + /// Settings for accessing Azure DevOps Server. + public AzureDevOpsPullRequestSystem(ICakeLog log, AzureDevOpsPullRequestSystemSettings settings) : base(log) { settings.NotNull(nameof(settings)); @@ -34,7 +33,7 @@ public TfsPullRequestSystem(ICakeLog log, TfsPullRequestSystemSettings settings) if (settings.CheckCommitId) { - this.AddCapability(new TfsCheckingCommitIdCapability(log, this)); + this.AddCapability(new AzureDevOpsCheckingCommitIdCapability(log, this)); this.Log.Information("Commit ID check capability is enabled."); } else @@ -44,7 +43,7 @@ public TfsPullRequestSystem(ICakeLog log, TfsPullRequestSystemSettings settings) if (settings.ManageDiscussionThreadStatus) { - this.AddCapability(new TfsDiscussionThreadsCapability(log, this)); + this.AddCapability(new AzureDevOpsDiscussionThreadsCapability(log, this)); this.Log.Information("Discussion thread status management capability is enabled."); } else @@ -54,30 +53,24 @@ public TfsPullRequestSystem(ICakeLog log, TfsPullRequestSystemSettings settings) // Filtering by modified files is always required as we otherwise no longer can compare issues // in a subsequent run as we lose information about file and line. - // See https://github.com/cake-contrib/Cake.Issues.PullRequests.Tfs/issues/46#issuecomment-419149355 - this.AddCapability(new TfsFilteringByModifiedFilesCapability(log, this)); + // See https://github.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/issues/46#issuecomment-419149355 + this.AddCapability(new AzureDevOpsFilteringByModifiedFilesCapability(log, this)); - this.tfsPullRequest = new TfsPullRequest(log, settings); + this.azureDevOpsPullRequest = new AzureDevOpsPullRequest(log, settings); } /// - TfsPullRequest ITfsPullRequestSystem.TfsPullRequest => this.tfsPullRequest; + AzureDevOpsPullRequest IAzureDevOpsPullRequestSystem.AzureDevOpsPullRequest => this.azureDevOpsPullRequest; /// public override bool Initialize(ReportIssuesToPullRequestSettings settings) { // Fail initialization if no pull request could be found. - return base.Initialize(settings) && this.tfsPullRequest.HasPullRequestLoaded; + return base.Initialize(settings) && this.azureDevOpsPullRequest.HasPullRequestLoaded; } /// - public override IssueCommentFormat GetPreferredCommentFormat() - { - return IssueCommentFormat.Markdown; - } - - /// - bool ITfsPullRequestSystem.ValidatePullRequest() + bool IAzureDevOpsPullRequestSystem.ValidatePullRequest() { return this.ValidatePullRequest(); } @@ -104,7 +97,7 @@ protected override void InternalPostDiscussionThreads(IEnumerable issues foreach (var thread in threads) { - this.tfsPullRequest.CreateCommentThread(thread); + this.azureDevOpsPullRequest.CreateCommentThread(thread); } this.Log.Information("Posted {0} discussion threads", threads.Count); @@ -131,13 +124,13 @@ private static void AddCodeFlowProperties( /// /// Validates if a pull request could be found. - /// Depending on + /// Depending on /// the pull request instance can not be successfully loaded. /// /// True if a valid pull request instance exists. private bool ValidatePullRequest() { - if (this.tfsPullRequest.HasPullRequestLoaded) + if (this.azureDevOpsPullRequest.HasPullRequestLoaded) { return true; } @@ -146,7 +139,7 @@ private bool ValidatePullRequest() return false; } - private IEnumerable CreateDiscussionThreads( + private IEnumerable CreateDiscussionThreads( IEnumerable issues, string commentSource) { @@ -154,19 +147,19 @@ private IEnumerable CreateDiscussionThreads( issues.NotNull(nameof(issues)); this.Log.Verbose("Creating new discussion threads"); - var result = new List(); + var result = new List(); // Code flow properties var iterationId = 0; - IEnumerable changes = null; + IEnumerable changes = null; - if (this.tfsPullRequest.CodeReviewId > 0) + if (this.azureDevOpsPullRequest.CodeReviewId > 0) { iterationId = this.GetCodeFlowLatestIterationId(); changes = this.GetCodeFlowChanges(iterationId); } - // Filter isues not related to a file. + // Filter issues not related to a file. if (!this.settings.ReportIssuesNotRelatedToAFile) { issues = issues.Where(x => x.AffectedFileRelativePath != null); @@ -180,14 +173,14 @@ private IEnumerable CreateDiscussionThreads( issue.Line, issue.AffectedFileRelativePath); - var newThread = new TfsPullRequestCommentThread() + var newThread = new AzureDevOpsPullRequestCommentThread() { - Status = TfsCommentThreadStatus.Active, + Status = AzureDevOpsCommentThreadStatus.Active, }; - var discussionComment = new TfsComment + var discussionComment = new AzureDevOpsComment { - CommentType = TfsCommentType.System, + CommentType = AzureDevOpsCommentType.System, IsDeleted = false, Content = ContentProvider.GetContent(issue), }; @@ -197,7 +190,7 @@ private IEnumerable CreateDiscussionThreads( continue; } - newThread.Comments = new List { discussionComment }; + newThread.Comments = new List { discussionComment }; result.Add(newThread); } @@ -205,8 +198,8 @@ private IEnumerable CreateDiscussionThreads( } private bool AddThreadProperties( - TfsPullRequestCommentThread thread, - IEnumerable changes, + AzureDevOpsPullRequestCommentThread thread, + IEnumerable changes, IIssue issue, int iterationId, string commentSource) @@ -219,7 +212,7 @@ private bool AddThreadProperties( if (issue.AffectedFileRelativePath != null) { - if (this.tfsPullRequest.CodeReviewId > 0) + if (this.azureDevOpsPullRequest.CodeReviewId > 0) { var changeTrackingId = this.TryGetCodeFlowChangeTrackingId(changes, issue.AffectedFileRelativePath); @@ -247,21 +240,21 @@ private bool AddThreadProperties( // Add a custom property to be able to return issue message from existing threads, // without any formatting done by this addin, back to Cake.Issues.PullRequests. - thread.SetIssueMessage(issue.Message); + thread.SetIssueMessage(issue.MessageText); return true; } private int GetCodeFlowLatestIterationId() { - var iterationId = this.tfsPullRequest.GetLatestIterationId(); + var iterationId = this.azureDevOpsPullRequest.GetLatestIterationId(); this.Log.Verbose("Determined iteration ID: {0}", iterationId); return iterationId; } - private IEnumerable GetCodeFlowChanges(int iterationId) + private IEnumerable GetCodeFlowChanges(int iterationId) { - var changes = this.tfsPullRequest.GetIterationChanges(iterationId); + var changes = this.azureDevOpsPullRequest.GetIterationChanges(iterationId); if (changes != null) { @@ -271,7 +264,7 @@ private IEnumerable GetCodeFlowChanges(int iterat return changes; } - private int TryGetCodeFlowChangeTrackingId(IEnumerable changes, FilePath path) + private int TryGetCodeFlowChangeTrackingId(IEnumerable changes, FilePath path) { changes.NotNull(nameof(changes)); path.NotNull(nameof(path)); diff --git a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemAliases.PullRequestSystem.cs b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases.PullRequestSystem.cs similarity index 62% rename from src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemAliases.PullRequestSystem.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases.PullRequestSystem.cs index da69a61..acf2ce0 100644 --- a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemAliases.PullRequestSystem.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases.PullRequestSystem.cs @@ -1,18 +1,18 @@ -namespace Cake.Issues.PullRequests.Tfs +namespace Cake.Issues.PullRequests.AzureDevOps { using System; + using Cake.AzureDevOps.Authentication; using Cake.Core; using Cake.Core.Annotations; - using Cake.Tfs.Authentication; /// - /// Contains functionality related to . + /// Contains functionality related to . /// - public static partial class TfsPullRequestSystemAliases + public static partial class AzureDevOpsPullRequestSystemAliases { /// - /// Gets an object for writing issues to Team Foundation Server or Azure DevOps pull request - /// in a specific repository and for a specific source branch. + /// Gets an object for writing issues to Azure DevOps pull request in a specific repository and for a + /// specific source branch. /// /// The context. /// Full URL of the Git repository, @@ -20,44 +20,42 @@ public static partial class TfsPullRequestSystemAliases /// Supported URL schemes are HTTP, HTTPS and SSH. /// URLs using SSH scheme are converted to HTTPS. /// Branch for which the pull request is made. - /// Credentials to use to authenticate against Team Foundation Server or - /// Azure DevOps. - /// Object for writing issues to Team Foundation Server or Azure DevOps pull request. + /// Credentials to use to authenticate against Azure DevOps. + /// Object for writing issues to Azure DevOps pull request. /// - /// Report code analysis issues reported as MsBuild warnings to a TFS pull request: + /// Report code analysis issues reported as MsBuild warnings to an Azure DevOps pull request: /// /// /// /// [CakeMethodAlias] [CakeAliasCategory(PullRequestsAliasConstants.PullRequestSystemCakeAliasCategory)] - public static IPullRequestSystem TfsPullRequests( + public static IPullRequestSystem AzureDevOpsPullRequests( this ICakeContext context, Uri repositoryUrl, string sourceBranch, - ITfsCredentials credentials) + IAzureDevOpsCredentials credentials) { context.NotNull(nameof(context)); repositoryUrl.NotNull(nameof(repositoryUrl)); sourceBranch.NotNullOrWhiteSpace(nameof(sourceBranch)); credentials.NotNull(nameof(credentials)); - return context.TfsPullRequests(new TfsPullRequestSystemSettings(repositoryUrl, sourceBranch, credentials)); + return context.AzureDevOpsPullRequests(new AzureDevOpsPullRequestSystemSettings(repositoryUrl, sourceBranch, credentials)); } /// - /// Gets an object for writing issues to Team Foundation Server or Azure DevOps pull request - /// in a specific repository and with a specific ID. + /// Gets an object for writing issues to Azure DevOps pull request in a specific repository and with a specific ID. /// /// The context. /// Full URL of the Git repository, @@ -65,139 +63,136 @@ public static IPullRequestSystem TfsPullRequests( /// Supported URL schemes are HTTP, HTTPS and SSH. /// URLs using SSH scheme are converted to HTTPS. /// ID of the pull request. - /// Credentials to use to authenticate against Team Foundation Server or - /// Azure DevOps. - /// Object for writing issues to Team Foundation Server or Azure DevOps pull request. + /// Credentials to use to authenticate against Azure DevOps. + /// Object for writing issues to Azure DevOps pull request. /// - /// Report code analysis issues reported as MsBuild warnings to a TFS pull request: + /// Report code analysis issues reported as MsBuild warnings to an Azure DevOps Server pull request: /// /// /// /// [CakeMethodAlias] [CakeAliasCategory(PullRequestsAliasConstants.PullRequestSystemCakeAliasCategory)] - public static IPullRequestSystem TfsPullRequests( + public static IPullRequestSystem AzureDevOpsPullRequests( this ICakeContext context, Uri repositoryUrl, int pullRequestId, - ITfsCredentials credentials) + IAzureDevOpsCredentials credentials) { context.NotNull(nameof(context)); repositoryUrl.NotNull(nameof(repositoryUrl)); credentials.NotNull(nameof(credentials)); - return context.TfsPullRequests(new TfsPullRequestSystemSettings(repositoryUrl, pullRequestId, credentials)); + return context.AzureDevOpsPullRequests(new AzureDevOpsPullRequestSystemSettings(repositoryUrl, pullRequestId, credentials)); } /// - /// Gets an object for writing issues to Team Foundation Server or Azure DevOps pull request - /// where all required data is taken from the environment variables set by the Azure Pipelines / TFS build. + /// Gets an object for writing issues to Azure DevOps pull request where all required data is taken + /// from the environment variables set by Azure Pipelines. /// /// The context. - /// Credentials to use to authenticate against Team Foundation Server or - /// Azure DevOps. - /// Object for writing issues to Team Foundation Server or Azure DevOps pull request. + /// Credentials to use to authenticate against Azure DevOps. + /// Object for writing issues to Azure DevOps pull request. /// - /// Report code analysis issues reported as MsBuild warnings to a TFS pull request: + /// Report code analysis issues reported as MsBuild warnings to an Azure DevOps Server pull request: /// /// /// /// [CakeMethodAlias] [CakeAliasCategory(PullRequestsAliasConstants.PullRequestSystemCakeAliasCategory)] - public static IPullRequestSystem TfsPullRequests( + public static IPullRequestSystem AzureDevOpsPullRequests( this ICakeContext context, - ITfsCredentials credentials) + IAzureDevOpsCredentials credentials) { context.NotNull(nameof(context)); credentials.NotNull(nameof(credentials)); - return context.TfsPullRequests(new TfsPullRequestSystemSettings(credentials)); + return context.AzureDevOpsPullRequests(new AzureDevOpsPullRequestSystemSettings(credentials)); } /// - /// Gets an object for writing issues to Team Foundation Server or Azure DevOps pull request - /// where all required data (including authentication token) is taken from the environment variables set by the Azure Pipelines / TFS build. + /// Gets an object for writing issues to Azure DevOps pull request where all required data (including authentication token) + /// is taken from the environment variables set by Azure Pipelines. /// /// The context. - /// Object for writing issues to Team Foundation Server or Azure DevOps pull request. + /// Object for writing issues to Azure DevOps pull request. /// - /// Report code analysis issues reported as MsBuild warnings to a TFS pull request: + /// Report code analysis issues reported as MsBuild warnings to an Azure DevOps pull request: /// /// /// /// [CakeMethodAlias] [CakeAliasCategory(PullRequestsAliasConstants.PullRequestSystemCakeAliasCategory)] - public static IPullRequestSystem TfsPullRequests( + public static IPullRequestSystem AzureDevOpsPullRequests( this ICakeContext context) { context.NotNull(nameof(context)); - return context.TfsPullRequests(new TfsPullRequestSystemSettings()); + return context.AzureDevOpsPullRequests(new AzureDevOpsPullRequestSystemSettings()); } /// - /// Gets an object for writing issues to Team Foundation Server or Visual Studio Team Services pull request - /// using the specified settings. + /// Gets an object for writing issues to Azure DevOps pull request using the specified settings. /// /// The context. /// Settings for accessing the pull request system. - /// Object for writing issues to Team Foundation Server or Azure DevOps pull request. + /// Object for writing issues to Azure DevOps pull request. /// - /// Report code analysis issues reported as MsBuild warnings to a TFS pull request: + /// Report code analysis issues reported as MsBuild warnings to an Azure DevOps Server pull request: /// /// /// /// [CakeMethodAlias] [CakeAliasCategory(PullRequestsAliasConstants.PullRequestSystemCakeAliasCategory)] - public static IPullRequestSystem TfsPullRequests( + public static IPullRequestSystem AzureDevOpsPullRequests( this ICakeContext context, - TfsPullRequestSystemSettings settings) + AzureDevOpsPullRequestSystemSettings settings) { context.NotNull(nameof(context)); settings.NotNull(nameof(settings)); - return new TfsPullRequestSystem(context.Log, settings); + return new AzureDevOpsPullRequestSystem(context.Log, settings); } } } diff --git a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemAliases.cs b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases.cs similarity index 55% rename from src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemAliases.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases.cs index 518c7d3..5ac2340 100644 --- a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemAliases.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases.cs @@ -1,13 +1,12 @@ -namespace Cake.Issues.PullRequests.Tfs +namespace Cake.Issues.PullRequests.AzureDevOps { using Cake.Core.Annotations; /// - /// Contains functionality related to writing code analysis issues to Team Foundation Server or - /// Azure DevOps pull requests. + /// Contains functionality related to writing code analysis issues to Azure DevOps pull requests. /// [CakeAliasCategory(IssuesAliasConstants.MainCakeAliasCategory)] - public static partial class TfsPullRequestSystemAliases + public static partial class AzureDevOpsPullRequestSystemAliases { } } diff --git a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemSettings.cs b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemSettings.cs similarity index 61% rename from src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemSettings.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemSettings.cs index 12ebd5d..ac5c3eb 100644 --- a/src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystemSettings.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemSettings.cs @@ -1,72 +1,68 @@ -namespace Cake.Issues.PullRequests.Tfs +namespace Cake.Issues.PullRequests.AzureDevOps { using System; - using Cake.Tfs.Authentication; - using Cake.Tfs.PullRequest; + using Cake.AzureDevOps.Authentication; + using Cake.AzureDevOps.PullRequest; /// - /// Settings for . + /// Settings for . /// - public class TfsPullRequestSystemSettings : TfsPullRequestSettings + public class AzureDevOpsPullRequestSystemSettings : AzureDevOpsPullRequestSettings { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Full URL of the Git repository, /// eg. http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository. /// Supported URL schemes are HTTP, HTTPS and SSH. /// URLs using SSH scheme are converted to HTTPS. /// Branch for which the pull request is made. - /// Credentials to use to authenticate against Team Foundation Server or - /// Azure DevOps. - public TfsPullRequestSystemSettings(Uri repositoryUrl, string sourceBranch, ITfsCredentials credentials) + /// Credentials to use to authenticate against Azure DevOps. + public AzureDevOpsPullRequestSystemSettings(Uri repositoryUrl, string sourceBranch, IAzureDevOpsCredentials credentials) : base(repositoryUrl, sourceBranch, credentials) { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Full URL of the Git repository, /// eg. http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository. /// Supported URL schemes are HTTP, HTTPS and SSH. /// URLs using SSH scheme are converted to HTTPS. /// ID of the pull request. - /// Credentials to use to authenticate against Team Foundation Server or - /// Azure DevOps. - public TfsPullRequestSystemSettings(Uri repositoryUrl, int pullRequestId, ITfsCredentials credentials) + /// Credentials to use to authenticate against Azure DevOps. + public AzureDevOpsPullRequestSystemSettings(Uri repositoryUrl, int pullRequestId, IAzureDevOpsCredentials credentials) : base(repositoryUrl, pullRequestId, credentials) { } /// - /// Initializes a new instance of the class - /// based on the instance of a class. + /// Initializes a new instance of the class + /// based on the instance of a class. /// /// Settings containing the parameters. - public TfsPullRequestSystemSettings(TfsPullRequestSettings settings) + public AzureDevOpsPullRequestSystemSettings(AzureDevOpsPullRequestSettings settings) : base(settings) { } /// - /// Initializes a new instance of the class - /// based on the environment variables set by the Azure Pipelines / TFS build. + /// Initializes a new instance of the class + /// based on the environment variables set by the Azure Pipelines. /// - /// Credentials to use to authenticate against Team Foundation Server or - /// Azure DevOps. - public TfsPullRequestSystemSettings(ITfsCredentials credentials) + /// Credentials to use to authenticate against Azure DevOps. + public AzureDevOpsPullRequestSystemSettings(IAzureDevOpsCredentials credentials) : base(credentials) { } /// - /// Initializes a new instance of the class - /// based on the environment variables set by the Azure Pipelines / TFS build - /// using the build authentication token. + /// Initializes a new instance of the class + /// based on the environment variables set by the Azure Pipelines using the build authentication token. /// - public TfsPullRequestSystemSettings() - : base(UsingTfsBuildOAuthToken()) + public AzureDevOpsPullRequestSystemSettings() + : base(UsingAzurePipelinesOAuthToken()) { } diff --git a/src/Cake.Issues.PullRequests.Tfs/Cake.Issues.PullRequests.Tfs.csproj b/src/Cake.Issues.PullRequests.AzureDevOps/Cake.Issues.PullRequests.AzureDevOps.csproj similarity index 66% rename from src/Cake.Issues.PullRequests.Tfs/Cake.Issues.PullRequests.Tfs.csproj rename to src/Cake.Issues.PullRequests.AzureDevOps/Cake.Issues.PullRequests.AzureDevOps.csproj index 534d2df..d09e464 100644 --- a/src/Cake.Issues.PullRequests.Tfs/Cake.Issues.PullRequests.Tfs.csproj +++ b/src/Cake.Issues.PullRequests.AzureDevOps/Cake.Issues.PullRequests.AzureDevOps.csproj @@ -7,17 +7,17 @@ full true - ..\Cake.Issues.PullRequests.Tfs.ruleset + ..\Cake.Issues.PullRequests.AzureDevOps.ruleset latest - Cake.Issues.PullRequests.Tfs + Cake.Issues.PullRequests.AzureDevOps -The Azure DevOps / Azure DevOps Server support for the Cake.Issues addin for Cake allows you to -write found issues as comments to Azure DevOps or Azure DevOps Server pull requests. +The Azure DevOps support for the Cake.Issues addin for Cake allows you to +write found issues as comments to Azure DevOps pull requests. -This addin provides the aliases for writing to Azure DevOps or Azure DevOps Server pull requests. +This addin provides the aliases for writing to Azure DevOps pull requests. It also requires the core Cake.Issues and Cake.Issues.PullRequests addins and one or more issue providers. See the Project Site for an overview of the whole ecosystem of addins for working with issues in Cake scripts. @@ -25,29 +25,32 @@ See the Project Site for an overview of the whole ecosystem of addins for workin BBT Software AG and contributors Copyright © BBT Software AG and contributors Cake Script Cake-Issues Cake-PullRequestSystem Issues PullRequest TFS Azure-DevOps Azure-DevOps-Server - https://cdn.jsdelivr.net/gh/cake-contrib/graphics@a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png + icon.png https://cakeissues.net MIT git - https://github.com/cake-contrib/Cake.Issues.PullRequests.Tfs.git - https://github.com/cake-contrib/Cake.Issues.PullRequests.Tfs/releases/tag/0.7.2 + https://github.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps.git + https://github.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/releases/tag/0.8.0 - bin\Debug\netstandard2.0\Cake.Issues.PullRequests.Tfs.xml + bin\Debug\netstandard2.0\Cake.Issues.PullRequests.AzureDevOps.xml - bin\Release\netstandard2.0\Cake.Issues.PullRequests.Tfs.xml + bin\Release\netstandard2.0\Cake.Issues.PullRequests.AzureDevOps.xml - - - - + + + + + + + \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCheckingCommitIdCapability.cs b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCheckingCommitIdCapability.cs similarity index 54% rename from src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCheckingCommitIdCapability.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCheckingCommitIdCapability.cs index 6af80f4..3517f23 100644 --- a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCheckingCommitIdCapability.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCheckingCommitIdCapability.cs @@ -1,18 +1,18 @@ -namespace Cake.Issues.PullRequests.Tfs.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Capabilities { using Cake.Core.Diagnostics; /// - /// Implementation of a for . + /// Implementation of a for . /// - internal class TfsCheckingCommitIdCapability : BaseCheckingCommitIdCapability + internal class AzureDevOpsCheckingCommitIdCapability : BaseCheckingCommitIdCapability { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The Cake log context. /// Pull request system to which this capability belongs. - public TfsCheckingCommitIdCapability(ICakeLog log, ITfsPullRequestSystem pullRequestSystem) + public AzureDevOpsCheckingCommitIdCapability(ICakeLog log, IAzureDevOpsPullRequestSystem pullRequestSystem) : base(log, pullRequestSystem) { } @@ -25,7 +25,7 @@ public override string GetLastSourceCommitId() return string.Empty; } - return this.PullRequestSystem.TfsPullRequest.LastSourceCommitId; + return this.PullRequestSystem.AzureDevOpsPullRequest.LastSourceCommitId; } } } diff --git a/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCommentExtensions.cs b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCommentExtensions.cs new file mode 100644 index 0000000..a687e82 --- /dev/null +++ b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCommentExtensions.cs @@ -0,0 +1,26 @@ +namespace Cake.Issues.PullRequests.AzureDevOps.Capabilities +{ + using Cake.AzureDevOps.PullRequest.CommentThread; + + /// + /// Extensions for . + /// + internal static class AzureDevOpsCommentExtensions + { + /// + /// Converts a from Azure DevOps to a as used in this addin. + /// + /// Azure DevOps comment to convert. + /// Converted comment. + public static IPullRequestDiscussionComment ToPullRequestDiscussionComment(this AzureDevOpsComment comment) + { + comment.NotNull(nameof(comment)); + + return new PullRequestDiscussionComment() + { + Content = comment.Content, + IsDeleted = comment.IsDeleted, + }; + } + } +} diff --git a/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCommentThreadStatusExtensions.cs b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCommentThreadStatusExtensions.cs new file mode 100644 index 0000000..60571ad --- /dev/null +++ b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsCommentThreadStatusExtensions.cs @@ -0,0 +1,58 @@ +namespace Cake.Issues.PullRequests.AzureDevOps.Capabilities +{ + using Cake.AzureDevOps.PullRequest.CommentThread; + + /// + /// Extensions for enumeration. + /// + internal static class AzureDevOpsCommentThreadStatusExtensions + { + /// + /// Converts a from Azure DevOps to a as used in this addin. + /// + /// Azure DevOps status to convert. + /// Converted status. + public static PullRequestDiscussionStatus ToPullRequestDiscussionStatus(this AzureDevOpsCommentThreadStatus status) + { + switch (status) + { + case AzureDevOpsCommentThreadStatus.Unknown: + return PullRequestDiscussionStatus.Unknown; + case AzureDevOpsCommentThreadStatus.Active: + case AzureDevOpsCommentThreadStatus.Pending: + return PullRequestDiscussionStatus.Active; + case AzureDevOpsCommentThreadStatus.Fixed: + case AzureDevOpsCommentThreadStatus.WontFix: + case AzureDevOpsCommentThreadStatus.Closed: + case AzureDevOpsCommentThreadStatus.ByDesign: + return PullRequestDiscussionStatus.Resolved; + default: + throw new PullRequestIssuesException("Unknown enumeration value"); + } + } + + /// + /// Converts a from Azure DevOps to a as used in this addin. + /// + /// Azure DevOps status to convert. + /// Converted status. + public static PullRequestDiscussionResolution ToPullRequestDiscussionResolution(this AzureDevOpsCommentThreadStatus status) + { + switch (status) + { + case AzureDevOpsCommentThreadStatus.Unknown: + case AzureDevOpsCommentThreadStatus.Active: + case AzureDevOpsCommentThreadStatus.Pending: + return PullRequestDiscussionResolution.Unknown; + case AzureDevOpsCommentThreadStatus.Fixed: + case AzureDevOpsCommentThreadStatus.Closed: + case AzureDevOpsCommentThreadStatus.ByDesign: + return PullRequestDiscussionResolution.Resolved; + case AzureDevOpsCommentThreadStatus.WontFix: + return PullRequestDiscussionResolution.WontFix; + default: + throw new PullRequestIssuesException("Unknown enumeration value"); + } + } + } +} diff --git a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsDiscussionThreadsCapability.cs b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsDiscussionThreadsCapability.cs similarity index 76% rename from src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsDiscussionThreadsCapability.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsDiscussionThreadsCapability.cs index c6e758c..ec22c9c 100644 --- a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsDiscussionThreadsCapability.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsDiscussionThreadsCapability.cs @@ -1,20 +1,20 @@ -namespace Cake.Issues.PullRequests.Tfs.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Capabilities { using System.Collections.Generic; using System.Linq; using Cake.Core.Diagnostics; /// - /// Implementation of a for . + /// Implementation of a for . /// - internal class TfsDiscussionThreadsCapability : BaseDiscussionThreadsCapability + internal class AzureDevOpsDiscussionThreadsCapability : BaseDiscussionThreadsCapability { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The Cake log context. /// Pull request system to which this capability belongs. - public TfsDiscussionThreadsCapability(ICakeLog log, ITfsPullRequestSystem pullRequestSystem) + public AzureDevOpsDiscussionThreadsCapability(ICakeLog log, IAzureDevOpsPullRequestSystem pullRequestSystem) : base(log, pullRequestSystem) { } @@ -22,7 +22,7 @@ public TfsDiscussionThreadsCapability(ICakeLog log, ITfsPullRequestSystem pullRe /// protected override IEnumerable InternalFetchDiscussionThreads(string commentSource) { - var threads = this.PullRequestSystem.TfsPullRequest.GetCommentThreads(); + var threads = this.PullRequestSystem.AzureDevOpsPullRequest.GetCommentThreads(); var threadList = new List(); foreach (var thread in threads) @@ -55,7 +55,7 @@ protected override void InternalResolveDiscussionThreads(IEnumerable - /// Implementation of a for . + /// Implementation of a for . /// - internal class TfsFilteringByModifiedFilesCapability : BaseFilteringByModifiedFilesCapability + internal class AzureDevOpsFilteringByModifiedFilesCapability : BaseFilteringByModifiedFilesCapability { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The Cake log context. /// Pull request system to which this capability belongs. - public TfsFilteringByModifiedFilesCapability(ICakeLog log, ITfsPullRequestSystem pullRequestSystem) + public AzureDevOpsFilteringByModifiedFilesCapability(ICakeLog log, IAzureDevOpsPullRequestSystem pullRequestSystem) : base(log, pullRequestSystem) { } @@ -24,7 +24,7 @@ protected override IEnumerable InternalGetModifiedFilesInPullRequest() { this.Log.Verbose("Computing the list of files changed in this pull request..."); - return this.PullRequestSystem.TfsPullRequest.GetModifiedFiles(); + return this.PullRequestSystem.AzureDevOpsPullRequest.GetModifiedFiles(); } } } diff --git a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsPullRequestCommentThreadExtensions.cs b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsPullRequestCommentThreadExtensions.cs similarity index 74% rename from src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsPullRequestCommentThreadExtensions.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsPullRequestCommentThreadExtensions.cs index f89119f..eb2fe0f 100644 --- a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsPullRequestCommentThreadExtensions.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/Capabilities/AzureDevOpsPullRequestCommentThreadExtensions.cs @@ -1,22 +1,22 @@ -namespace Cake.Issues.PullRequests.Tfs.Capabilities +namespace Cake.Issues.PullRequests.AzureDevOps.Capabilities { using System.Linq; - using Cake.Tfs.PullRequest.CommentThread; + using Cake.AzureDevOps.PullRequest.CommentThread; /// - /// Extensions for . + /// Extensions for . /// - internal static class TfsPullRequestCommentThreadExtensions + internal static class AzureDevOpsPullRequestCommentThreadExtensions { private const string CommentSourcePropertyName = "CakeIssuesCommentSource"; private const string IssueMessagePropertyName = "CakeIssuesIssueMessage"; /// - /// Converts a from TFS to a as used in this addin. + /// Converts a from Azure DevOps to a as used in this addin. /// - /// TFS thread to convert. + /// Azure DevOps thread to convert. /// Converted thread. - public static IPullRequestDiscussionThread ToPullRequestDiscussionThread(this TfsPullRequestCommentThread thread) + public static IPullRequestDiscussionThread ToPullRequestDiscussionThread(this AzureDevOpsPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); @@ -36,7 +36,7 @@ public static IPullRequestDiscussionThread ToPullRequestDiscussionThread(this Tf /// /// Thread to get the value from. /// Comment source value. - public static string GetCommentSource(this TfsPullRequestCommentThread thread) + public static string GetCommentSource(this AzureDevOpsPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); @@ -48,7 +48,7 @@ public static string GetCommentSource(this TfsPullRequestCommentThread thread) /// /// Thread for which the value should be set. /// Value to set as comment source. - public static void SetCommentSource(this TfsPullRequestCommentThread thread, string value) + public static void SetCommentSource(this AzureDevOpsPullRequestCommentThread thread, string value) { thread.NotNull(nameof(thread)); @@ -62,7 +62,7 @@ public static void SetCommentSource(this TfsPullRequestCommentThread thread, str /// Thread to check. /// Value to check for. /// True if the value is identical, False otherwise. - public static bool IsCommentSource(this TfsPullRequestCommentThread thread, string value) + public static bool IsCommentSource(this AzureDevOpsPullRequestCommentThread thread, string value) { thread.NotNull(nameof(thread)); @@ -75,7 +75,7 @@ public static bool IsCommentSource(this TfsPullRequestCommentThread thread, stri /// /// Thread to get the value from. /// Original message of the issue. - public static string GetIssueMessage(this TfsPullRequestCommentThread thread) + public static string GetIssueMessage(this AzureDevOpsPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); @@ -87,7 +87,7 @@ public static string GetIssueMessage(this TfsPullRequestCommentThread thread) /// /// Thread for which the value should be set. /// Value to set as the original message. - public static void SetIssueMessage(this TfsPullRequestCommentThread thread, string value) + public static void SetIssueMessage(this AzureDevOpsPullRequestCommentThread thread, string value) { thread.NotNull(nameof(thread)); diff --git a/src/Cake.Issues.PullRequests.Tfs/ContentProvider.cs b/src/Cake.Issues.PullRequests.AzureDevOps/ContentProvider.cs similarity index 87% rename from src/Cake.Issues.PullRequests.Tfs/ContentProvider.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/ContentProvider.cs index 2fe6b49..0ab8382 100644 --- a/src/Cake.Issues.PullRequests.Tfs/ContentProvider.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/ContentProvider.cs @@ -1,4 +1,4 @@ -namespace Cake.Issues.PullRequests.Tfs +namespace Cake.Issues.PullRequests.AzureDevOps { /// /// Class for providing the content for a pull request comment. @@ -12,7 +12,7 @@ internal static class ContentProvider /// Comment content for the issue. public static string GetContent(IIssue issue) { - var result = issue.Message; + var result = issue.Message(IssueCommentFormat.Markdown); if (string.IsNullOrWhiteSpace(issue.Rule)) { return result; diff --git a/src/Cake.Issues.PullRequests.Tfs/ITfsPullRequestSystem.cs b/src/Cake.Issues.PullRequests.AzureDevOps/IAzureDevOpsPullRequestSystem.cs similarity index 51% rename from src/Cake.Issues.PullRequests.Tfs/ITfsPullRequestSystem.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/IAzureDevOpsPullRequestSystem.cs index bcec27d..96887cf 100644 --- a/src/Cake.Issues.PullRequests.Tfs/ITfsPullRequestSystem.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/IAzureDevOpsPullRequestSystem.cs @@ -1,20 +1,20 @@ -namespace Cake.Issues.PullRequests.Tfs +namespace Cake.Issues.PullRequests.AzureDevOps { - using Cake.Tfs.PullRequest; + using Cake.AzureDevOps.PullRequest; /// - /// Interface for writing issues to Team Foundation Server or Azure DevOps pull requests. + /// Interface for writing issues to Azure DevOps pull requests. /// - internal interface ITfsPullRequestSystem : IPullRequestSystem + internal interface IAzureDevOpsPullRequestSystem : IPullRequestSystem { /// /// Gets information about the pull request. /// - TfsPullRequest TfsPullRequest { get; } + AzureDevOpsPullRequest AzureDevOpsPullRequest { get; } /// /// Validates if a pull request could be found. - /// Depending on + /// Depending on /// the pull request instance can be null for subsequent calls. /// /// True if a valid pull request instance exists. diff --git a/src/Cake.Issues.PullRequests.Tfs/Properties/AssemblyInfo.cs b/src/Cake.Issues.PullRequests.AzureDevOps/Properties/AssemblyInfo.cs similarity index 88% rename from src/Cake.Issues.PullRequests.Tfs/Properties/AssemblyInfo.cs rename to src/Cake.Issues.PullRequests.AzureDevOps/Properties/AssemblyInfo.cs index 8a2d63f..8467724 100644 --- a/src/Cake.Issues.PullRequests.Tfs/Properties/AssemblyInfo.cs +++ b/src/Cake.Issues.PullRequests.AzureDevOps/Properties/AssemblyInfo.cs @@ -11,5 +11,5 @@ [assembly: Guid("1d046545-035b-4d7e-98c8-8ae6f5d0d289")] [assembly: CLSCompliant(true)] -[assembly: InternalsVisibleTo("Cake.Issues.PullRequests.Tfs.Tests")] +[assembly: InternalsVisibleTo("Cake.Issues.PullRequests.AzureDevOps.Tests")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // Required for NSubstitute \ No newline at end of file diff --git a/src/Cake.Issues.PullRequests.Tfs/app.config b/src/Cake.Issues.PullRequests.AzureDevOps/app.config similarity index 100% rename from src/Cake.Issues.PullRequests.Tfs/app.config rename to src/Cake.Issues.PullRequests.AzureDevOps/app.config diff --git a/src/Cake.Issues.PullRequests.AzureDevOps/icon.png b/src/Cake.Issues.PullRequests.AzureDevOps/icon.png new file mode 100644 index 0000000..9881edc Binary files /dev/null and b/src/Cake.Issues.PullRequests.AzureDevOps/icon.png differ diff --git a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCommentExtensions.cs b/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCommentExtensions.cs deleted file mode 100644 index a963e57..0000000 --- a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCommentExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace Cake.Issues.PullRequests.Tfs.Capabilities -{ - using Cake.Tfs.PullRequest.CommentThread; - - /// - /// Extensions for . - /// - internal static class TfsCommentExtensions - { - /// - /// Converts a from TFS to a as used in this addin. - /// - /// TFS comment to convert. - /// Converted comment. - public static IPullRequestDiscussionComment ToPullRequestDiscussionComment(this TfsComment comment) - { - comment.NotNull(nameof(comment)); - - return new PullRequestDiscussionComment() - { - Content = comment.Content, - IsDeleted = comment.IsDeleted, - }; - } - } -} diff --git a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCommentThreadStatusExtensions.cs b/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCommentThreadStatusExtensions.cs deleted file mode 100644 index 2618276..0000000 --- a/src/Cake.Issues.PullRequests.Tfs/Capabilities/TfsCommentThreadStatusExtensions.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace Cake.Issues.PullRequests.Tfs.Capabilities -{ - using Cake.Tfs.PullRequest.CommentThread; - - /// - /// Extensions for enumeration. - /// - internal static class TfsCommentThreadStatusExtensions - { - /// - /// Converts a from TFS to a as used in this addin. - /// - /// TFS status to convert. - /// Converted status. - public static PullRequestDiscussionStatus ToPullRequestDiscussionStatus(this TfsCommentThreadStatus status) - { - switch (status) - { - case TfsCommentThreadStatus.Unknown: - return PullRequestDiscussionStatus.Unknown; - case TfsCommentThreadStatus.Active: - case TfsCommentThreadStatus.Pending: - return PullRequestDiscussionStatus.Active; - case TfsCommentThreadStatus.Fixed: - case TfsCommentThreadStatus.WontFix: - case TfsCommentThreadStatus.Closed: - case TfsCommentThreadStatus.ByDesign: - return PullRequestDiscussionStatus.Resolved; - default: - throw new PullRequestIssuesException("Unknown enumeration value"); - } - } - - /// - /// Converts a from TFS to a as used in this addin. - /// - /// TFS status to convert. - /// Converted status. - public static PullRequestDiscussionResolution ToPullRequestDiscussionResolution(this TfsCommentThreadStatus status) - { - switch (status) - { - case TfsCommentThreadStatus.Unknown: - case TfsCommentThreadStatus.Active: - case TfsCommentThreadStatus.Pending: - return PullRequestDiscussionResolution.Unknown; - case TfsCommentThreadStatus.Fixed: - case TfsCommentThreadStatus.Closed: - case TfsCommentThreadStatus.ByDesign: - return PullRequestDiscussionResolution.Resolved; - case TfsCommentThreadStatus.WontFix: - return PullRequestDiscussionResolution.WontFix; - default: - throw new PullRequestIssuesException("Unknown enumeration value"); - } - } - } -}