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

Commit 5f75063

Browse files
authored
Merge branch 'master' into fixes/fix-pr-session-refactor
2 parents 799d5b9 + 3cf1784 commit 5f75063

File tree

27 files changed

+132
-95
lines changed

27 files changed

+132
-95
lines changed

src/GitHub.App/GitHub.App.csproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" />
3+
<Import Project="..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" />
44
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -47,8 +47,8 @@
4747
</PropertyGroup>
4848
<Import Project="$(SolutionDir)\src\common\signing.props" />
4949
<ItemGroup>
50-
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
51-
<HintPath>..\..\packages\LibGit2Sharp.0.22.0\lib\net40\LibGit2Sharp.dll</HintPath>
50+
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
51+
<HintPath>..\..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
5252
<Private>True</Private>
5353
</Reference>
5454
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -238,7 +238,9 @@
238238
</ItemGroup>
239239
<ItemGroup>
240240
<None Include="app.config" />
241-
<None Include="packages.config" />
241+
<None Include="packages.config">
242+
<SubType>Designer</SubType>
243+
</None>
242244
</ItemGroup>
243245
<ItemGroup>
244246
<ProjectReference Include="..\..\submodules\akavache\Akavache.Sqlite3\Akavache.Sqlite3.csproj">
@@ -309,7 +311,7 @@
309311
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
310312
</PropertyGroup>
311313
<Error Condition="!Exists('..\..\packages\SQLitePCL.raw_basic.0.7.3.0-vs2012\build\net45\SQLitePCL.raw_basic.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\SQLitePCL.raw_basic.0.7.3.0-vs2012\build\net45\SQLitePCL.raw_basic.targets'))" />
312-
<Error Condition="!Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props'))" />
314+
<Error Condition="!Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props'))" />
313315
</Target>
314316
<Import Project="..\..\packages\SQLitePCL.raw_basic.0.7.3.0-vs2012\build\net45\SQLitePCL.raw_basic.targets" Condition="Exists('..\..\packages\SQLitePCL.raw_basic.0.7.3.0-vs2012\build\net45\SQLitePCL.raw_basic.targets')" />
315317
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

src/GitHub.App/Services/GitClient.cs

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ public Task Pull(IRepository repository)
4343
return Task.Factory.StartNew(() =>
4444
{
4545
var signature = repository.Config.BuildSignature(DateTimeOffset.UtcNow);
46+
#pragma warning disable 0618 // TODO: Replace `Network.Pull` with `Commands.Pull`.
4647
repository.Network.Pull(signature, pullOptions);
48+
#pragma warning restore 0618
4749
});
4850
}
4951

@@ -74,7 +76,46 @@ public Task Fetch(IRepository repository, string remoteName)
7476
try
7577
{
7678
var remote = repository.Network.Remotes[remoteName];
79+
#pragma warning disable 0618 // TODO: Replace `Network.Fetch` with `Commands.Fetch`.
7780
repository.Network.Fetch(remote, fetchOptions);
81+
#pragma warning restore 0618
82+
}
83+
catch (Exception ex)
84+
{
85+
log.Error("Failed to fetch", ex);
86+
#if DEBUG
87+
throw;
88+
#endif
89+
}
90+
});
91+
}
92+
93+
public Task Fetch(IRepository repo, UriString cloneUrl, params string[] refspecs)
94+
{
95+
var httpsUrl = UriString.ToUriString(cloneUrl.ToRepositoryUrl());
96+
97+
var originRemote = repo.Network.Remotes[defaultOriginName];
98+
if (originRemote != null && originRemote.Url == httpsUrl)
99+
{
100+
return Fetch(repo, defaultOriginName, refspecs);
101+
}
102+
103+
return Task.Factory.StartNew(() =>
104+
{
105+
try
106+
{
107+
var tempRemoteName = cloneUrl.Owner + "-" + Guid.NewGuid();
108+
var remote = repo.Network.Remotes.Add(tempRemoteName, httpsUrl);
109+
try
110+
{
111+
#pragma warning disable 0618 // TODO: Replace `Network.Fetch` with `Commands.Fetch`.
112+
repo.Network.Fetch(remote, refspecs, fetchOptions);
113+
#pragma warning restore 0618
114+
}
115+
finally
116+
{
117+
repo.Network.Remotes.Remove(tempRemoteName);
118+
}
78119
}
79120
catch (Exception ex)
80121
{
@@ -96,7 +137,9 @@ public Task Fetch(IRepository repository, string remoteName, params string[] ref
96137
try
97138
{
98139
var remote = repository.Network.Remotes[remoteName];
140+
#pragma warning disable 0618 // TODO: Replace `Network.Fetch` with `Commands.Fetch`.
99141
repository.Network.Fetch(remote, refspecs, fetchOptions);
142+
#pragma warning restore 0618
100143
}
101144
catch (Exception ex)
102145
{
@@ -115,7 +158,9 @@ public Task Checkout(IRepository repository, string branchName)
115158

116159
return Task.Factory.StartNew(() =>
117160
{
161+
#pragma warning disable 0618 // TODO: Replace `IRepository.Checkout` with `Commands.Checkout`.
118162
repository.Checkout(branchName);
163+
#pragma warning restore 0618
119164
});
120165
}
121166

@@ -430,26 +475,6 @@ public Task<bool> IsHeadPushed(IRepository repo)
430475
});
431476
}
432477

433-
public Task Fetch(IRepository repo, UriString cloneUrl, params string[] refspecs)
434-
{
435-
var httpsUrl = UriString.ToUriString(cloneUrl.ToRepositoryUrl());
436-
if (repo.Network.Remotes[defaultOriginName]?.Url == httpsUrl)
437-
{
438-
return Fetch(repo, defaultOriginName, refspecs);
439-
}
440-
441-
var tempRemoteName = cloneUrl.Owner + "-" + Guid.NewGuid();
442-
repo.Network.Remotes.Add(tempRemoteName, httpsUrl);
443-
try
444-
{
445-
return Fetch(repo, tempRemoteName, refspecs);
446-
}
447-
finally
448-
{
449-
repo.Network.Remotes.Remove(tempRemoteName);
450-
}
451-
}
452-
453478
static bool IsCanonical(string s)
454479
{
455480
Guard.ArgumentNotEmptyString(s, nameof(s));

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ public IObservable<Unit> Push(ILocalRepositoryModel repository)
106106
return Observable.Defer(async () =>
107107
{
108108
var repo = gitService.GetRepository(repository.LocalPath);
109-
var remote = await gitClient.GetHttpRemote(repo, repo.Head.Remote.Name);
109+
var remoteName = repo.Head.RemoteName;
110+
var remote = await gitClient.GetHttpRemote(repo, remoteName);
110111
return gitClient.Push(repo, repo.Head.TrackedBranch.UpstreamBranchCanonicalName, remote.Name).ToObservable();
111112
});
112113
}
@@ -170,10 +171,10 @@ public IObservable<BranchTrackingDetails> CalculateHistoryDivergence(ILocalRepos
170171
return Observable.Defer(async () =>
171172
{
172173
var repo = gitService.GetRepository(repository.LocalPath);
173-
174-
if (repo.Head.Remote != null)
174+
var remoteName = repo.Head.RemoteName;
175+
if (remoteName != null)
175176
{
176-
var remote = await gitClient.GetHttpRemote(repo, repo.Head.Remote.Name);
177+
var remote = await gitClient.GetHttpRemote(repo, remoteName);
177178
await gitClient.Fetch(repo, remote.Name);
178179
}
179180

@@ -368,8 +369,8 @@ public IObservable<Unit> RemoveUnusedRemotes(ILocalRepositoryModel repository)
368369
var repo = gitService.GetRepository(repository.LocalPath);
369370
var usedRemotes = new HashSet<string>(
370371
repo.Branches
371-
.Where(x => !x.IsRemote && x.Remote != null)
372-
.Select(x => x.Remote?.Name));
372+
.Where(x => !x.IsRemote && x.RemoteName != null)
373+
.Select(x => x.RemoteName));
373374

374375
foreach (var remote in repo.Network.Remotes)
375376
{

src/GitHub.App/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="LibGit2Sharp" version="0.22.0" targetFramework="net461" />
4-
<package id="LibGit2Sharp.NativeBinaries" version="1.0.129" targetFramework="net461" />
3+
<package id="LibGit2Sharp" version="0.24.0" targetFramework="net461" />
4+
<package id="LibGit2Sharp.NativeBinaries" version="1.0.185" targetFramework="net461" />
55
<package id="Microsoft.VisualStudio.Shell.14.0" version="14.3.25407" targetFramework="net461" />
66
<package id="Microsoft.VisualStudio.Shell.Immutable.10.0" version="10.0.30319" targetFramework="net461" />
77
<package id="Microsoft.VisualStudio.TextManager.Interop" version="7.10.6070" targetFramework="net461" />

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" />
3+
<Import Project="..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" />
44
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -42,8 +42,8 @@
4242
</PropertyGroup>
4343
<Import Project="$(SolutionDir)\src\common\signing.props" />
4444
<ItemGroup>
45-
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
46-
<HintPath>..\..\packages\LibGit2Sharp.0.22.0\lib\net40\LibGit2Sharp.dll</HintPath>
45+
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
46+
<HintPath>..\..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
4747
<Private>True</Private>
4848
</Reference>
4949
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -205,7 +205,7 @@
205205
<PropertyGroup>
206206
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
207207
</PropertyGroup>
208-
<Error Condition="!Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props'))" />
208+
<Error Condition="!Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props'))" />
209209
</Target>
210210
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
211211
Other similar extension points exist, see Microsoft.Common.targets.

src/GitHub.Exports.Reactive/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="LibGit2Sharp" version="0.22.0" targetFramework="net461" />
4-
<package id="LibGit2Sharp.NativeBinaries" version="1.0.129" targetFramework="net461" />
3+
<package id="LibGit2Sharp" version="0.24.0" targetFramework="net461" />
4+
<package id="LibGit2Sharp.NativeBinaries" version="1.0.185" 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" />
77
<package id="Microsoft.VisualStudio.Text.Logic" version="14.3.25407" targetFramework="net461" />

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" />
3+
<Import Project="..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" />
44
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
55
<PropertyGroup>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -48,8 +48,8 @@
4848
<Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
4949
<EmbedInteropTypes>false</EmbedInteropTypes>
5050
</Reference>
51-
<Reference Include="LibGit2Sharp, Version=0.22.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
52-
<HintPath>..\..\packages\LibGit2Sharp.0.22.0\lib\net40\LibGit2Sharp.dll</HintPath>
51+
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
52+
<HintPath>..\..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
5353
<Private>True</Private>
5454
</Reference>
5555
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -277,7 +277,7 @@
277277
<PropertyGroup>
278278
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
279279
</PropertyGroup>
280-
<Error Condition="!Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\LibGit2Sharp.NativeBinaries.1.0.129\build\LibGit2Sharp.NativeBinaries.props'))" />
280+
<Error Condition="!Exists('..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props'))" />
281281
</Target>
282282
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
283283
Other similar extension points exist, see Microsoft.Common.targets.

src/GitHub.Exports/Models/BranchModel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ public BranchModel(LibGit2Sharp.Branch branch, IRepositoryModel repo)
2929
{
3030
Extensions.Guard.ArgumentNotNull(branch, nameof(branch));
3131
Extensions.Guard.ArgumentNotNull(repo, nameof(repo));
32-
3332
Name = DisplayName = branch.FriendlyName;
34-
Repository = branch.IsRemote ? new LocalRepositoryModel(branch.Remote.Url) : repo;
33+
#pragma warning disable 0618 // TODO: Replace `Branch.Remote` with `Repository.Network.Remotes[branch.RemoteName]`.
34+
var remoteUrl = branch.Remote.Url;
35+
#pragma warning restore 0618
36+
Repository = branch.IsRemote ? new LocalRepositoryModel(remoteUrl) : repo;
3537
IsTracking = branch.IsTracking;
3638
Id = String.Format(CultureInfo.InvariantCulture, "{0}/{1}", Repository.Owner, Name);
3739
}

src/GitHub.Exports/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="LibGit2Sharp" version="0.22.0" targetFramework="net461" />
4-
<package id="LibGit2Sharp.NativeBinaries" version="1.0.129" targetFramework="net461" />
3+
<package id="LibGit2Sharp" version="0.24.0" targetFramework="net461" />
4+
<package id="LibGit2Sharp.NativeBinaries" version="1.0.185" targetFramework="net461" />
55
<package id="Microsoft.VisualStudio.OLE.Interop" version="7.10.6070" targetFramework="net461" />
66
<package id="Microsoft.VisualStudio.Shell.14.0" version="14.3.25407" targetFramework="net461" />
77
<package id="Microsoft.VisualStudio.Shell.Immutable.10.0" version="10.0.30319" targetFramework="net461" />

0 commit comments

Comments
 (0)