Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
Replace TFS code with dependency to Cake.Tfs addin
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Aug 23, 2018
1 parent 81c445c commit 0b3403e
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<Compile Include="TfsDiscussionThreadsCapabilityTests.cs" />
<Compile Include="TfsCheckingCommitIdCapabilityTests.cs" />
<Compile Include="TfsCredentialsExtensionsTests.cs" />
<Compile Include="TfsPullRequestSettingsTests.cs" />
<Compile Include="TfsPullRequestSystemSettingsTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
using Testing;
using Xunit;

public sealed class TfsPullRequestSettingsTests
public sealed class TfsPullRequestSystemSettingsTests
{
public sealed class TheCtor
{
[Fact]
public void Should_Throw_If_RepositoryUrl_For_SourceBranch_Is_Null()
{
// Given / When
var result = Record.Exception(() => new TfsPullRequestSettings(null, "foo", null));
var result = Record.Exception(() => new TfsPullRequestSystemSettings(null, "foo", null));

// Then
result.IsArgumentNullException("repositoryUrl");
Expand All @@ -22,7 +22,7 @@ public void Should_Throw_If_RepositoryUrl_For_SourceBranch_Is_Null()
public void Should_Throw_If_SourceBranch_Is_Null()
{
// Given / When
var result = Record.Exception(() => new TfsPullRequestSettings(new Uri("http://example.com"), null, null));
var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), null, null));

// Then
result.IsArgumentNullException("sourceBranch");
Expand All @@ -32,7 +32,7 @@ public void Should_Throw_If_SourceBranch_Is_Null()
public void Should_Throw_If_SourceBranch_Is_Empty()
{
// Given / When
var result = Record.Exception(() => new TfsPullRequestSettings(new Uri("http://example.com"), string.Empty, null));
var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), string.Empty, null));

// Then
result.IsArgumentOutOfRangeException("sourceBranch");
Expand All @@ -42,7 +42,7 @@ public void Should_Throw_If_SourceBranch_Is_Empty()
public void Should_Throw_If_SourceBranch_Is_WhiteSpace()
{
// Given / When
var result = Record.Exception(() => new TfsPullRequestSettings(new Uri("http://example.com"), " ", null));
var result = Record.Exception(() => new TfsPullRequestSystemSettings(new Uri("http://example.com"), " ", null));

// Then
result.IsArgumentOutOfRangeException("sourceBranch");
Expand All @@ -52,7 +52,7 @@ public void Should_Throw_If_SourceBranch_Is_WhiteSpace()
public void Should_Throw_If_RepositoryUrl_For_PullRequestId_Is_Null()
{
// Given / When
var result = Record.Exception(() => new TfsPullRequestSettings(null, 0, null));
var result = Record.Exception(() => new TfsPullRequestSystemSettings(null, 0, null));

// Then
result.IsArgumentNullException("repositoryUrl");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<PackageReference Include="Cake.Issues" Version="0.6.0-beta0002" />
<PackageReference Include="Cake.Issues.PullRequests" Version="0.6.0-beta0002" />
<PackageReference Include="Cake.Tfs">
<Version>0.1.0-beta0001</Version>
<Version>0.1.0</Version>
</PackageReference>
<PackageReference Include="Costura.Fody">
<Version>3.1.0</Version>
Expand All @@ -61,7 +61,6 @@
<PackageReference Include="StyleCop.Analyzers">
<Version>1.0.2</Version>
</PackageReference>
<PackageReference Include="TfsUrlParser" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -86,7 +85,7 @@
<Compile Include="TfsCheckingCommitIdCapability.cs" />
<Compile Include="TfsCredentialsExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TfsPullRequestSettings.cs" />
<Compile Include="TfsPullRequestSystemSettings.cs" />
<Compile Include="TfsPullRequestSystem.cs" />
<Compile Include="TfsPullRequestSystemAliases.PullRequestSystem.cs" />
<Compile Include="TfsPullRequestSystemAliases.cs" />
Expand Down
1 change: 1 addition & 0 deletions src/Cake.Issues.PullRequests.Tfs/FodyWeavers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Costura>
<ExcludeAssemblies>
Cake.Core
Cake.Tfs
Cake.Issues
Cake.Issues.PullRequests
Costura
Expand Down
13 changes: 4 additions & 9 deletions src/Cake.Issues.PullRequests.Tfs/ITfsPullRequestSystem.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
namespace Cake.Issues.PullRequests.Tfs
{
using Cake.Tfs.PullRequest;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using TfsUrlParser;

/// <summary>
/// Interface for writing issues to Team Foundation Server or Visual Studio Team Services pull requests.
/// </summary>
internal interface ITfsPullRequestSystem : IPullRequestSystem
{
/// <summary>
/// Gets the description of the repository.
/// Gets information about the pull request.
/// </summary>
RepositoryDescription RepositoryDescription { get; }

/// <summary>
/// Gets the object to access the pull request.
/// </summary>
GitPullRequest PullRequest { get; }
TfsPullRequest TfsPullRequest { get; }

/// <summary>
/// Validates if a pull request could be found.
/// Depending on <see cref="TfsPullRequestSettings.ThrowExceptionIfPullRequestDoesNotExist"/>
/// Depending on <see cref="TfsPullRequestSettings.ThrowExceptionIfPullRequestCouldNotBeFound"/>
/// the pull request instance can be null for subsequent calls.
/// </summary>
/// <returns>True if a valid pull request instance exists.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override string GetLastSourceCommitId()
return string.Empty;
}

return this.PullRequestSystem.PullRequest.LastMergeSourceCommit.CommitId;
return this.PullRequestSystem.TfsPullRequest.LastSourceCommitId;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ protected override IEnumerable<IPullRequestDiscussionThread> InternalFetchDiscus
{
var request =
gitClient.GetThreadsAsync(
this.PullRequestSystem.PullRequest.Repository.Id,
this.PullRequestSystem.PullRequest.PullRequestId,
this.PullRequestSystem.TfsPullRequest.RepositoryId,
this.PullRequestSystem.TfsPullRequest.PullRequestId,
null,
null,
null,
Expand Down Expand Up @@ -88,8 +88,8 @@ protected override void InternalResolveDiscussionThreads(IEnumerable<IPullReques

gitClient.UpdateThreadAsync(
newThread,
this.PullRequestSystem.PullRequest.Repository.Id,
this.PullRequestSystem.PullRequest.PullRequestId,
this.PullRequestSystem.TfsPullRequest.RepositoryId,
this.PullRequestSystem.TfsPullRequest.PullRequestId,
thread.Id,
null,
CancellationToken.None).Wait();
Expand Down Expand Up @@ -120,8 +120,8 @@ protected override void InternalReopenDiscussionThreads(IEnumerable<IPullRequest

gitClient.UpdateThreadAsync(
newThread,
this.PullRequestSystem.PullRequest.Repository.Id,
this.PullRequestSystem.PullRequest.PullRequestId,
this.PullRequestSystem.TfsPullRequest.RepositoryId,
this.PullRequestSystem.TfsPullRequest.PullRequestId,
thread.Id,
null,
CancellationToken.None).Wait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ protected override IEnumerable<FilePath> InternalGetModifiedFilesInPullRequest()
var targetVersionDescriptor = new GitTargetVersionDescriptor
{
VersionType = GitVersionType.Commit,
Version = this.PullRequestSystem.PullRequest.LastMergeSourceCommit.CommitId
Version = this.PullRequestSystem.TfsPullRequest.LastSourceCommitId
};

var baseVersionDescriptor = new GitBaseVersionDescriptor
{
VersionType = GitVersionType.Commit,
Version = this.PullRequestSystem.PullRequest.LastMergeTargetCommit.CommitId
Version = this.PullRequestSystem.TfsPullRequest.LastSourceCommitId
};

using (var gitClient = this.PullRequestSystem.CreateGitClient())
{
var commitDiffs = gitClient.GetCommitDiffsAsync(
this.PullRequestSystem.RepositoryDescription.ProjectName,
this.PullRequestSystem.RepositoryDescription.RepositoryName,
this.PullRequestSystem.TfsPullRequest.ProjectName,
this.PullRequestSystem.TfsPullRequest.RepositoryName,
true, // bool? diffCommonCommit
null, // int? top
null, // int? skip
Expand Down
79 changes: 0 additions & 79 deletions src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSettings.cs

This file was deleted.

Loading

0 comments on commit 0b3403e

Please sign in to comment.