Skip to content

Commit 1792f51

Browse files
committed
Remote Proxy
1 parent 5a3ba69 commit 1792f51

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

src/GitVersionCore.Tests/Core/RepositoryExtensionsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Branch = GitVersion.Branch;
1313
using BranchCollection = GitVersion.BranchCollection;
1414
using ReferenceCollection = GitVersion.ReferenceCollection;
15+
using Remote = GitVersion.Remote;
1516

1617
namespace GitVersionCore.Tests
1718
{

src/GitVersionCore.Tests/Mocks/MockRepository.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using GitVersion;
33
using GitVersion.Logging;
4-
using Remote = LibGit2Sharp.Remote;
54
namespace GitVersionCore.Tests.Mocks
65
{
76
public class MockRepository : IGitRepository

src/GitVersionCore/Core/Abstractions/IGitRepository.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using GitVersion.Logging;
3-
using LibGit2Sharp;
43

54
namespace GitVersion
65
{

src/GitVersionCore/Core/GitModel.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.Linq;
45
using GitVersion.Helpers;
56
using LibGit2Sharp;
67
using LibGit2Sharp.Handlers;
@@ -131,6 +132,25 @@ protected Branch()
131132
public virtual bool IsTracking => innerBranch != null && innerBranch.IsTracking;
132133
}
133134

135+
public class Remote
136+
{
137+
private readonly LibGit2Sharp.Remote innerRemote;
138+
139+
private Remote(LibGit2Sharp.Remote remote)
140+
{
141+
innerRemote = remote;
142+
}
143+
144+
protected Remote()
145+
{
146+
}
147+
public static implicit operator LibGit2Sharp.Remote(Remote d) => d?.innerRemote;
148+
public static explicit operator Remote(LibGit2Sharp.Remote b) => b is null ? null : new Remote(b);
149+
public virtual string Name => innerRemote.Name;
150+
public virtual string Url => innerRemote.Url;
151+
public virtual string RefSpecs => string.Join(", ", innerRemote.FetchRefSpecs.Select(r => r.Specification));
152+
}
153+
134154
public class BranchCollection : IEnumerable<Branch>
135155
{
136156
private readonly LibGit2Sharp.BranchCollection innerCollection;

src/GitVersionCore/Core/GitPreparer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private void NormalizeGitDirectory(string gitDirectory, bool noFetch, string cur
157157
}
158158
else
159159
{
160-
log.Info($"Fetching from remote '{remote.Name}' using the following refspecs: {string.Join(", ", remote.FetchRefSpecs.Select(r => r.Specification))}.");
160+
log.Info($"Fetching from remote '{remote.Name}' using the following refspecs: {remote.RefSpecs}.");
161161
repository.Commands.Fetch(remote.Name, new string[0], authentication, null);
162162
}
163163

src/GitVersionCore/Core/GitRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ public Remote EnsureOnlyOneRemoteIsDefined(ILog log)
206206
var remote = remotes.Single();
207207
log.Info($"One remote found ({remote.Name} -> '{remote.Url}').");
208208
AddMissingRefSpecs(log, remote);
209-
return remote;
209+
return (Remote)remote;
210210
}
211211

212212
var message = $"{howMany} remote(s) have been detected. When being run on a build server, the Git repository is expected to bear one (and no more than one) remote.";
213213
throw new WarningException(message);
214214
}
215215

216-
private void AddMissingRefSpecs(ILog log, Remote remote)
216+
private void AddMissingRefSpecs(ILog log, LibGit2Sharp.Remote remote)
217217
{
218218
if (remote.FetchRefSpecs.Any(r => r.Source == "refs/heads/*"))
219219
return;

0 commit comments

Comments
 (0)