Skip to content

Commit

Permalink
(cake-contribGH-25) Update Cake.Issues to 0.4.0-beta.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jul 26, 2018
1 parent b265af1 commit 3035eef
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.28.0" />
<PackageReference Include="Cake.Issues" Version="0.3.0" />
<PackageReference Include="Cake.Issues.Testing" Version="0.3.0" />
<PackageReference Include="Cake.Issues" Version="0.4.0-beta0001" />
<PackageReference Include="Cake.Issues.Testing" Version="0.4.0-beta0001" />
<PackageReference Include="Cake.Testing" Version="0.28.0" />
<PackageReference Include="Shouldly" Version="3.0.0" />
<PackageReference Include="StyleCop.Analyzers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.28.0" />
<PackageReference Include="Cake.Issues" Version="0.3.0" />
<PackageReference Include="Cake.Issues.PullRequests" Version="0.3.0" />
<PackageReference Include="Cake.Issues" Version="0.4.0-beta0001" />
<PackageReference Include="Cake.Issues.PullRequests" Version="0.4.0-beta0001" />
<PackageReference Include="Costura.Fody">
<Version>2.0.1</Version>
</PackageReference>
Expand Down
24 changes: 24 additions & 0 deletions src/Cake.Issues.PullRequests.Tfs/CommentThreadStatusExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,29 @@ public static PullRequestDiscussionStatus ToPullRequestDiscussionStatus(this Com
throw new PullRequestIssuesException("Unknown enumeration value");
}
}

/// <summary>
/// Converts a <see cref="CommentThreadStatus"/> from TFS to a <see cref="PullRequestDiscussionResolution"/> as used in this addin.
/// </summary>
/// <param name="status">TFS status to convert.</param>
/// <returns>Converted status.</returns>
public static PullRequestDiscussionResolution ToPullRequestDiscussionResolution(this CommentThreadStatus status)
{
switch (status)
{
case CommentThreadStatus.Unknown:
case CommentThreadStatus.Active:
case CommentThreadStatus.Pending:
return PullRequestDiscussionResolution.Unknown;
case CommentThreadStatus.Fixed:
case CommentThreadStatus.Closed:
case CommentThreadStatus.ByDesign:
return PullRequestDiscussionResolution.Resolved;
case CommentThreadStatus.WontFix:
return PullRequestDiscussionResolution.WontFix;
default:
throw new PullRequestIssuesException("Unknown enumeration value");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static IPullRequestDiscussionThread ToPullRequestDiscussionThread(this Gi
thread.Comments.Select(x => x.ToPullRequestDiscussionComment()))
{
CommentSource = thread.GetCommentSource(),
Resolution = thread.Status.ToPullRequestDiscussionResolution()
};
}

Expand Down
38 changes: 35 additions & 3 deletions src/Cake.Issues.PullRequests.Tfs/TfsPullRequestSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public override IssueCommentFormat GetPreferredCommentFormat()
}

/// <inheritdoc/>
protected override IEnumerable<IPullRequestDiscussionThread> InternalFetchActiveDiscussionThreads(string commentSource)
protected override IEnumerable<IPullRequestDiscussionThread> InternalFetchDiscussionThreads(string commentSource)
{
if (!this.ValidatePullRequest())
{
Expand All @@ -184,7 +184,7 @@ protected override IEnumerable<IPullRequestDiscussionThread> InternalFetchActive
var threadList = new List<IPullRequestDiscussionThread>();
foreach (var thread in threads)
{
if (!thread.IsCommentSource(commentSource) || thread.Status != CommentThreadStatus.Active)
if (!thread.IsCommentSource(commentSource))
{
continue;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ from change in commitDiffs.Changes
}

/// <inheritdoc/>
protected override void InternalMarkThreadsAsFixed(IEnumerable<IPullRequestDiscussionThread> threads)
protected override void InternalResolveDiscussionThreads(IEnumerable<IPullRequestDiscussionThread> threads)
{
// ReSharper disable once PossibleMultipleEnumeration
threads.NotNull(nameof(threads));
Expand Down Expand Up @@ -290,6 +290,38 @@ protected override void InternalMarkThreadsAsFixed(IEnumerable<IPullRequestDiscu
}
}

/// <inheritdoc/>
protected override void InternalReopenDiscussionThreads(IEnumerable<IPullRequestDiscussionThread> threads)
{
// ReSharper disable once PossibleMultipleEnumeration
threads.NotNull(nameof(threads));

if (!this.ValidatePullRequest())
{
return;
}

using (var gitClient = this.CreateGitClient())
{
// ReSharper disable once PossibleMultipleEnumeration
foreach (var thread in threads)
{
var newThread = new GitPullRequestCommentThread
{
Status = CommentThreadStatus.Active
};

gitClient.UpdateThreadAsync(
newThread,
this.pullRequest.Repository.Id,
this.pullRequest.PullRequestId,
thread.Id,
null,
CancellationToken.None).Wait();
}
}
}

/// <inheritdoc/>
protected override void InternalPostDiscussionThreads(IEnumerable<IIssue> issues, string commentSource)
{
Expand Down

0 comments on commit 3035eef

Please sign in to comment.