Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 7405f86

Browse files
authored
Merge pull request #1229 from github/refactor/pr-sessions-revert
Revert "Merge pull request #1219 from github/refactor/pr-sessions"
2 parents a61b79c + a34d90c commit 7405f86

28 files changed

+1159
-2123
lines changed

Diff for: src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj

+1-9
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@
5454
<HintPath>..\..\packages\Microsoft.VisualStudio.Text.Data.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.Data.dll</HintPath>
5555
<Private>True</Private>
5656
</Reference>
57-
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
58-
<HintPath>..\..\packages\Microsoft.VisualStudio.Text.Logic.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.Logic.dll</HintPath>
59-
<Private>True</Private>
60-
</Reference>
61-
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
62-
<HintPath>..\..\packages\Microsoft.VisualStudio.Text.UI.14.3.25407\lib\net45\Microsoft.VisualStudio.Text.UI.dll</HintPath>
63-
<Private>True</Private>
64-
</Reference>
6557
<Reference Include="PresentationCore" />
6658
<Reference Include="System" />
6759
<Reference Include="System.ComponentModel.Composition" />
@@ -103,8 +95,8 @@
10395
<Compile Include="GlobalSuppressions.cs" />
10496
<Compile Include="Models\IAvatarContainer.cs" />
10597
<Compile Include="Models\IConnectionRepositoryHostMap.cs" />
98+
<Compile Include="Models\IEditorContentSource.cs" />
10699
<Compile Include="Models\IInlineCommentThreadModel.cs" />
107-
<Compile Include="Models\IPullRequestSessionLiveFile.cs" />
108100
<Compile Include="Models\IPullRequestSessionFile.cs" />
109101
<Compile Include="Models\IRepositoryHosts.cs" />
110102
<Compile Include="Models\PullRequestTextBufferInfo.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace GitHub.Models
5+
{
6+
/// <summary>
7+
/// Represents a source of editor content for a <see cref="IPullRequestSessionFile"/>.
8+
/// </summary>
9+
public interface IEditorContentSource
10+
{
11+
/// <summary>
12+
/// Gets the file contents from the editor.
13+
/// </summary>
14+
/// <returns>A task returning the editor content.</returns>
15+
Task<byte[]> GetContent();
16+
}
17+
}

Diff for: src/GitHub.Exports.Reactive/Models/IPullRequestSessionFile.cs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
using System;
22
using System.Collections.Generic;
33
using System.ComponentModel;
4+
using GitHub.Services;
45

56
namespace GitHub.Models
67
{
78
/// <summary>
8-
/// Represents a file in a pull request.
9+
/// A file in a pull request session.
910
/// </summary>
1011
/// <remarks>
11-
/// A <see cref="IPullRequestSessionFile"/> holds the review comments for a file in a pull
12-
/// request together with associated information such as the commit SHA of the file and the
13-
/// diff with the file's merge base.
12+
/// A pull request session file represents the real-time state of a file in a pull request in
13+
/// the IDE. If the pull request branch is checked out, it represents the state of a file from
14+
/// the pull request model updated to the current state of the code on disk and in the editor.
1415
/// </remarks>
1516
/// <seealso cref="IPullRequestSession"/>
1617
/// <seealso cref="IPullRequestSessionManager"/>
1718
public interface IPullRequestSessionFile : INotifyPropertyChanged
1819
{
19-
/// <summary>
20-
/// Gets the SHA of the base commit of the file in the pull request.
21-
/// </summary>
22-
string BaseSha { get; }
23-
2420
/// <summary>
2521
/// Gets the SHA of the current commit of the file, or null if the file has uncommitted
2622
/// changes.
@@ -35,7 +31,12 @@ public interface IPullRequestSessionFile : INotifyPropertyChanged
3531
/// <summary>
3632
/// Gets the diff between the PR merge base and the current state of the file.
3733
/// </summary>
38-
IReadOnlyList<DiffChunk> Diff { get; }
34+
IList<DiffChunk> Diff { get; }
35+
36+
/// <summary>
37+
/// Gets the source for the editor contents for the file.
38+
/// </summary>
39+
IEditorContentSource ContentSource { get; }
3940

4041
/// <summary>
4142
/// Gets the inline comments threads for the file.

Diff for: src/GitHub.Exports.Reactive/Models/IPullRequestSessionLiveFile.cs

-23
This file was deleted.

Diff for: src/GitHub.Exports.Reactive/Models/PullRequestTextBufferInfo.cs

+6-7
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,25 @@ namespace GitHub.Models
55
{
66
/// <summary>
77
/// When attached as a property to a Visual Studio ITextBuffer, informs the inline comment
8-
/// tagger that the buffer represents a buffer opened from a pull request at the HEAD commit
9-
/// of a pull request.
8+
/// tagger that the buffer represents a buffer opened from a pull request.
109
/// </summary>
1110
public class PullRequestTextBufferInfo
1211
{
1312
/// <summary>
1413
/// Initializes a new instance of the <see cref="PullRequestTextBufferInfo"/> class.
1514
/// </summary>
1615
/// <param name="session">The pull request session.</param>
17-
/// <param name="relativePath">The relative path to the file in the repository.</param>
16+
/// <param name="filePath">The full path to the file.</param>
1817
/// <param name="isLeftComparisonBuffer">
1918
/// Whether the buffer represents the left-hand-side of a comparison.
2019
/// </param>
2120
public PullRequestTextBufferInfo(
2221
IPullRequestSession session,
23-
string relativePath,
22+
string filePath,
2423
bool isLeftComparisonBuffer)
2524
{
2625
Session = session;
27-
RelativePath = relativePath;
26+
FilePath = filePath;
2827
IsLeftComparisonBuffer = isLeftComparisonBuffer;
2928
}
3029

@@ -34,9 +33,9 @@ public PullRequestTextBufferInfo(
3433
public IPullRequestSession Session { get; }
3534

3635
/// <summary>
37-
/// Gets the relative path to the file in the repository.
36+
/// Gets the full path to the file.
3837
/// </summary>
39-
public string RelativePath { get; }
38+
public string FilePath { get; }
4039

4140
/// <summary>
4241
/// Gets a value indicating whether the buffer represents the left-hand-side of a comparison.

Diff for: src/GitHub.Exports.Reactive/Services/IPullRequestSession.cs

+33-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
44
using GitHub.Models;
5+
using ReactiveUI;
56

67
namespace GitHub.Services
78
{
89
/// <summary>
9-
/// A pull request session used to display inline comments.
10+
/// A pull request session used to display inline reviews.
1011
/// </summary>
12+
/// <remarks>
13+
/// A pull request session represents the real-time state of a pull request in the IDE.
14+
/// It takes the pull request model and updates according to the current state of the
15+
/// repository on disk and in the editor.
16+
/// </remarks>
1117
public interface IPullRequestSession
1218
{
1319
/// <summary>
@@ -59,10 +65,26 @@ public interface IPullRequestSession
5965
Task<IPullRequestSessionFile> GetFile(string relativePath);
6066

6167
/// <summary>
62-
/// Gets the merge base SHA for the pull request.
68+
/// Gets a file touched by the pull request.
69+
/// </summary>
70+
/// <param name="relativePath">The relative path to the file.</param>
71+
/// <param name="contentSource">The editor file content source.</param>
72+
/// <returns>
73+
/// A <see cref="IPullRequestSessionFile"/> object or null if the file was not touched by
74+
/// the pull request.
75+
/// </returns>
76+
Task<IPullRequestSessionFile> GetFile(
77+
string relativePath,
78+
IEditorContentSource contentSource);
79+
80+
/// <summary>
81+
/// Converts a path to a path relative to the current repository.
6382
/// </summary>
64-
/// <returns>The merge base SHA.</returns>
65-
Task<string> GetMergeBase();
83+
/// <param name="path">The path.</param>
84+
/// <returns>
85+
/// The relative path, or null if the specified path is not in the repository.
86+
/// </returns>
87+
string GetRelativePath(string path);
6688

6789
/// <summary>
6890
/// Posts a new PR review comment.
@@ -89,5 +111,12 @@ public interface IPullRequestSession
89111
/// <param name="pullRequest">The new pull request model.</param>
90112
/// <returns>A task which completes when the session has completed updating.</returns>
91113
Task Update(IPullRequestModel pullRequest);
114+
115+
/// <summary>
116+
/// Notifies the session that the contents of a file in the editor have changed.
117+
/// </summary>
118+
/// <param name="relativePath">The relative path to the file.</param>
119+
/// <returns>A task which completes when the session has completed updating.</returns>
120+
Task UpdateEditorContent(string relativePath);
92121
}
93122
}

Diff for: src/GitHub.Exports.Reactive/Services/IPullRequestSessionManager.cs

-33
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,12 @@
33
using System.Threading.Tasks;
44
using GitHub.Models;
55
using Microsoft.VisualStudio.Text;
6-
using Microsoft.VisualStudio.Text.Editor;
76

87
namespace GitHub.Services
98
{
109
/// <summary>
1110
/// Manages pull request sessions.
1211
/// </summary>
13-
/// <remarks>
14-
/// If the currently checked out branch represents a pull request then <see cref="CurrentSession"/>
15-
/// will return an <see cref="IPullRequestSession"/> containing the details of that pull request.
16-
/// A session for any other pull request can also be retrieved by calling
17-
/// <see cref="GetSession(IPullRequestModel)"/>.
18-
///
19-
/// Calling <see cref="GetLiveFile(string, ITextView, ITextBuffer)"/> will return an
20-
/// <see cref="IPullRequestSessionFile"/> which tracks both the contents of a text buffer and the
21-
/// current session, and updates the review comments in real-time.
22-
/// </remarks>
2312
public interface IPullRequestSessionManager : INotifyPropertyChanged
2413
{
2514
/// <summary>
@@ -31,28 +20,6 @@ public interface IPullRequestSessionManager : INotifyPropertyChanged
3120
/// </returns>
3221
IPullRequestSession CurrentSession { get; }
3322

34-
/// <summary>
35-
/// Gets an <see cref="IPullRequestSessionFile"/> that tracks the live state of a document.
36-
/// </summary>
37-
/// <param name="relativePath">The relative path to the file in the repository.</param>
38-
/// <param name="textView">The text view that is showing the file.</param>
39-
/// <param name="textBuffer">The text buffer with the file contents.</param>
40-
/// <returns>An <see cref="IPullRequestSessionLiveFile"/>.</returns>
41-
Task<IPullRequestSessionLiveFile> GetLiveFile(
42-
string relativePath,
43-
ITextView textView,
44-
ITextBuffer textBuffer);
45-
46-
/// <summary>
47-
/// Gets the path of a document displayed in a text buffer, relative to the current
48-
/// repository.
49-
/// </summary>
50-
/// <param name="buffer">The text buffer.</param>
51-
/// <returns>
52-
/// The relative path, or null if the buffer does not represent a file in the repository.
53-
/// </returns>
54-
string GetRelativePath(ITextBuffer buffer);
55-
5623
/// <summary>
5724
/// Gets a pull request session for a pull request that may not be checked out.
5825
/// </summary>

Diff for: src/GitHub.Exports.Reactive/packages.config

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
<package id="LibGit2Sharp.NativeBinaries" version="1.0.129" targetFramework="net461" />
55
<package id="Microsoft.VisualStudio.CoreUtility" version="14.3.25407" targetFramework="net461" />
66
<package id="Microsoft.VisualStudio.Text.Data" version="14.3.25407" targetFramework="net461" />
7-
<package id="Microsoft.VisualStudio.Text.Logic" version="14.3.25407" targetFramework="net461" />
8-
<package id="Microsoft.VisualStudio.Text.UI" version="14.3.25407" targetFramework="net461" />
97
<package id="Rx-Core" version="2.2.5-custom" targetFramework="net45" />
108
<package id="Rx-Interfaces" version="2.2.5-custom" targetFramework="net45" />
119
<package id="Rx-Linq" version="2.2.5-custom" targetFramework="net45" />

Diff for: src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
<Compile Include="Glyph\IGlyphFactory.cs" />
7676
<Compile Include="InlineReviewsPackage.cs" />
7777
<Compile Include="Models\InlineCommentThreadModel.cs" />
78-
<Compile Include="Models\PullRequestSessionLiveFile.cs" />
7978
<Compile Include="Models\PullRequestSessionFile.cs" />
8079
<Compile Include="Tags\MouseEnterAndLeaveEventRouter.cs" />
8180
<Compile Include="Peek\InlineCommentPeekableItem.cs" />

Diff for: src/GitHub.InlineReviews/Models/InlineCommentThreadModel.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace GitHub.InlineReviews.Models
1313
class InlineCommentThreadModel : ReactiveObject, IInlineCommentThreadModel
1414
{
1515
bool isStale;
16-
int lineNumber = -1;
16+
int lineNumber;
1717

1818
/// <summary>
1919
/// Initializes a new instance of the <see cref="InlineCommentThreadModel"/> class.
@@ -33,7 +33,6 @@ public InlineCommentThreadModel(
3333
IList<DiffLine> diffMatch,
3434
IEnumerable<IPullRequestReviewCommentModel> comments)
3535
{
36-
Guard.ArgumentNotNull(relativePath, nameof(relativePath));
3736
Guard.ArgumentNotNull(originalCommitSha, nameof(originalCommitSha));
3837
Guard.ArgumentNotNull(diffMatch, nameof(diffMatch));
3938

Diff for: src/GitHub.InlineReviews/Models/PullRequestSessionFile.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
using System.Collections.Generic;
33
using GitHub.Models;
44
using ReactiveUI;
5+
using GitHub.InlineReviews.Services;
56

67
namespace GitHub.InlineReviews.Models
78
{
89
/// <summary>
910
/// A file in a pull request session.
1011
/// </summary>
1112
/// <remarks>
12-
/// A <see cref="PullRequestSessionFile"/> holds the review comments for a file in a pull
13-
/// request together with associated information such as the commit SHA of the file and the
14-
/// diff with the file's merge base.
13+
/// A pull request session file represents the real-time state of a file in a pull request in
14+
/// the IDE. If the pull request branch is checked out, it represents the state of a file from
15+
/// the pull request model updated to the current state of the code on disk and in the editor.
1516
/// </remarks>
1617
/// <seealso cref="PullRequestSession"/>
1718
/// <seealso cref="PullRequestSessionManager"/>
18-
public class PullRequestSessionFile : ReactiveObject, IPullRequestSessionFile
19+
class PullRequestSessionFile : ReactiveObject, IPullRequestSessionFile
1920
{
20-
IReadOnlyList<DiffChunk> diff;
21+
IList<DiffChunk> diff;
2122
string commitSha;
2223
IReadOnlyList<IInlineCommentThreadModel> inlineCommentThreads;
2324

@@ -36,7 +37,7 @@ public PullRequestSessionFile(string relativePath)
3637
public string RelativePath { get; }
3738

3839
/// <inheritdoc/>
39-
public IReadOnlyList<DiffChunk> Diff
40+
public IList<DiffChunk> Diff
4041
{
4142
get { return diff; }
4243
internal set { this.RaiseAndSetIfChanged(ref diff, value); }
@@ -53,7 +54,10 @@ public string CommitSha
5354
}
5455

5556
/// <inheritdoc/>
56-
public virtual IReadOnlyList<IInlineCommentThreadModel> InlineCommentThreads
57+
public IEditorContentSource ContentSource { get; internal set; }
58+
59+
/// <inheritdoc/>
60+
public IReadOnlyList<IInlineCommentThreadModel> InlineCommentThreads
5761
{
5862
get { return inlineCommentThreads; }
5963
internal set { this.RaiseAndSetIfChanged(ref inlineCommentThreads, value); }

0 commit comments

Comments
 (0)