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

Commit a34d90c

Browse files
committed
Revert "Merge pull request #1219 from github/refactor/pr-sessions"
This reverts commit 37690f7, reversing changes made to 7825fc2.
1 parent a61b79c commit a34d90c

28 files changed

+1159
-2123
lines changed

src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj

Lines changed: 1 addition & 9 deletions
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" />
Lines changed: 17 additions & 0 deletions
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+
}

src/GitHub.Exports.Reactive/Models/IPullRequestSessionFile.cs

Lines changed: 11 additions & 10 deletions
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.

src/GitHub.Exports.Reactive/Models/IPullRequestSessionLiveFile.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/GitHub.Exports.Reactive/Models/PullRequestTextBufferInfo.cs

Lines changed: 6 additions & 7 deletions
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.

src/GitHub.Exports.Reactive/Services/IPullRequestSession.cs

Lines changed: 33 additions & 4 deletions
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
}

src/GitHub.Exports.Reactive/Services/IPullRequestSessionManager.cs

Lines changed: 0 additions & 33 deletions
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>

src/GitHub.Exports.Reactive/packages.config

Lines changed: 0 additions & 2 deletions
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" />

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 0 additions & 1 deletion
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" />

src/GitHub.InlineReviews/Models/InlineCommentThreadModel.cs

Lines changed: 1 addition & 2 deletions
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

0 commit comments

Comments
 (0)