Skip to content

Commit 27c95e6

Browse files
committed
Move Network overloads to Extensions
1 parent 7ff3d29 commit 27c95e6

File tree

2 files changed

+240
-214
lines changed

2 files changed

+240
-214
lines changed

LibGit2Sharp/Network.cs

Lines changed: 2 additions & 214 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,6 @@ public virtual RemoteCollection Remotes
3737
get { return remotes.Value; }
3838
}
3939

40-
/// <summary>
41-
/// List references in a <see cref="Remote"/> repository.
42-
/// <para>
43-
/// When the remote tips are ahead of the local ones, the retrieved
44-
/// <see cref="DirectReference"/>s may point to non existing
45-
/// <see cref="GitObject"/>s in the local repository. In that
46-
/// case, <see cref="DirectReference.Target"/> will return <c>null</c>.
47-
/// </para>
48-
/// </summary>
49-
/// <param name="remote">The <see cref="Remote"/> to list from.</param>
50-
/// <returns>The references in the <see cref="Remote"/> repository.</returns>
51-
public virtual IEnumerable<DirectReference> ListReferences(Remote remote)
52-
{
53-
return ListReferences(remote, null);
54-
}
55-
5640
/// <summary>
5741
/// List references in a <see cref="Remote"/> repository.
5842
/// <para>
@@ -69,28 +53,12 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote, Creden
6953
{
7054
Ensure.ArgumentNotNull(remote, "remote");
7155

72-
using (RemoteSafeHandle remoteHandle = BuildRemoteSafeHandle(repository.Handle, remote.Name))
56+
using (RemoteSafeHandle remoteHandle = BuildRemoteSafeHandle(repository.Handle, remote))
7357
{
7458
return ListReferences(remoteHandle, credentialsProvider);
7559
}
7660
}
7761

78-
/// <summary>
79-
/// List references in a remote repository.
80-
/// <para>
81-
/// When the remote tips are ahead of the local ones, the retrieved
82-
/// <see cref="DirectReference"/>s may point to non existing
83-
/// <see cref="GitObject"/>s in the local repository. In that
84-
/// case, <see cref="DirectReference.Target"/> will return <c>null</c>.
85-
/// </para>
86-
/// </summary>
87-
/// <param name="url">The url to list from.</param>
88-
/// <returns>The references in the remote repository.</returns>
89-
public virtual IEnumerable<DirectReference> ListReferences(string url)
90-
{
91-
return ListReferences(url, null);
92-
}
93-
9462
/// <summary>
9563
/// List references in a remote repository.
9664
/// <para>
@@ -204,35 +172,6 @@ private static void DoFetch(FetchOptions options, RemoteSafeHandle remoteHandle,
204172
Proxy.git_remote_fetch(remoteHandle, refspecs, fetchOptions, logMessage);
205173
}
206174

207-
/// <summary>
208-
/// Fetch from the <see cref="Remote"/>.
209-
/// </summary>
210-
/// <param name="remote">The remote to fetch</param>
211-
public virtual void Fetch(Remote remote)
212-
{
213-
Fetch(remote, (FetchOptions)null, null);
214-
}
215-
216-
/// <summary>
217-
/// Fetch from the <see cref="Remote"/>.
218-
/// </summary>
219-
/// <param name="remote">The remote to fetch</param>
220-
/// <param name="options"><see cref="FetchOptions"/> controlling fetch behavior</param>
221-
public virtual void Fetch(Remote remote, FetchOptions options)
222-
{
223-
Fetch(remote, options, null);
224-
}
225-
226-
/// <summary>
227-
/// Fetch from the <see cref="Remote"/>.
228-
/// </summary>
229-
/// <param name="remote">The remote to fetch</param>
230-
/// <param name="logMessage">Message to use when updating the reflog.</param>
231-
public virtual void Fetch(Remote remote, string logMessage)
232-
{
233-
Fetch(remote, (FetchOptions)null, logMessage);
234-
}
235-
236175
/// <summary>
237176
/// Fetch from the <see cref="Remote"/>.
238177
/// </summary>
@@ -246,38 +185,6 @@ public virtual void Fetch(Remote remote, FetchOptions options, string logMessage
246185
DoFetch(repository.Handle, remote, options, logMessage, new string[0]);
247186
}
248187

249-
/// <summary>
250-
/// Fetch from the <see cref="Remote"/>, using custom refspecs.
251-
/// </summary>
252-
/// <param name="remote">The remote to fetch</param>
253-
/// <param name="refspecs">Refspecs to use, replacing the remote's fetch refspecs</param>
254-
public virtual void Fetch(Remote remote, IEnumerable<string> refspecs)
255-
{
256-
Fetch(remote, refspecs, null, null);
257-
}
258-
259-
/// <summary>
260-
/// Fetch from the <see cref="Remote"/>, using custom refspecs.
261-
/// </summary>
262-
/// <param name="remote">The remote to fetch</param>
263-
/// <param name="refspecs">Refspecs to use, replacing the remote's fetch refspecs</param>
264-
/// <param name="options"><see cref="FetchOptions"/> controlling fetch behavior</param>
265-
public virtual void Fetch(Remote remote, IEnumerable<string> refspecs, FetchOptions options)
266-
{
267-
Fetch(remote, refspecs, options, null);
268-
}
269-
270-
/// <summary>
271-
/// Fetch from the <see cref="Remote"/>, using custom refspecs.
272-
/// </summary>
273-
/// <param name="remote">The remote to fetch</param>
274-
/// <param name="refspecs">Refspecs to use, replacing the remote's fetch refspecs</param>
275-
/// <param name="logMessage">Message to use when updating the reflog.</param>
276-
public virtual void Fetch(Remote remote, IEnumerable<string> refspecs, string logMessage)
277-
{
278-
Fetch(remote, refspecs, null, logMessage);
279-
}
280-
281188
/// <summary>
282189
/// Fetch from the <see cref="Remote"/>, using custom refspecs.
283190
/// </summary>
@@ -293,46 +200,6 @@ public virtual void Fetch(Remote remote, IEnumerable<string> refspecs, FetchOpti
293200
DoFetch(repository.Handle, remote, options, logMessage, refspecs);
294201
}
295202

296-
/// <summary>
297-
/// Fetch from a url with a set of fetch refspecs
298-
/// </summary>
299-
/// <param name="url">The url to fetch from</param>
300-
/// <param name="refspecs">The list of resfpecs to use</param>
301-
public virtual void Fetch(
302-
string url,
303-
IEnumerable<string> refspecs)
304-
{
305-
Fetch(url, refspecs, null, null);
306-
}
307-
308-
/// <summary>
309-
/// Fetch from a url with a set of fetch refspecs
310-
/// </summary>
311-
/// <param name="url">The url to fetch from</param>
312-
/// <param name="refspecs">The list of resfpecs to use</param>
313-
/// <param name="options"><see cref="FetchOptions"/> controlling fetch behavior</param>
314-
public virtual void Fetch(
315-
string url,
316-
IEnumerable<string> refspecs,
317-
FetchOptions options)
318-
{
319-
Fetch(url, refspecs, options, null);
320-
}
321-
322-
/// <summary>
323-
/// Fetch from a url with a set of fetch refspecs
324-
/// </summary>
325-
/// <param name="url">The url to fetch from</param>
326-
/// <param name="refspecs">The list of resfpecs to use</param>
327-
/// <param name="logMessage">Message to use when updating the reflog.</param>
328-
public virtual void Fetch(
329-
string url,
330-
IEnumerable<string> refspecs,
331-
string logMessage)
332-
{
333-
Fetch(url, refspecs, null, logMessage);
334-
}
335-
336203
/// <summary>
337204
/// Fetch from a url with a set of fetch refspecs
338205
/// </summary>
@@ -352,85 +219,6 @@ public virtual void Fetch(
352219
DoFetch(repository.Handle, url, options, logMessage, refspecs);
353220
}
354221

355-
/// <summary>
356-
/// Push the objectish to the destination reference on the <see cref="Remote"/>.
357-
/// </summary>
358-
/// <param name="remote">The <see cref="Remote"/> to push to.</param>
359-
/// <param name="objectish">The source objectish to push.</param>
360-
/// <param name="destinationSpec">The reference to update on the remote.</param>
361-
public virtual void Push(
362-
Remote remote,
363-
string objectish,
364-
string destinationSpec)
365-
{
366-
Ensure.ArgumentNotNull(objectish, "objectish");
367-
Ensure.ArgumentNotNullOrEmptyString(destinationSpec, "destinationSpec");
368-
369-
Push(remote, string.Format(CultureInfo.InvariantCulture,
370-
"{0}:{1}", objectish, destinationSpec));
371-
}
372-
373-
/// <summary>
374-
/// Push the objectish to the destination reference on the <see cref="Remote"/>.
375-
/// </summary>
376-
/// <param name="remote">The <see cref="Remote"/> to push to.</param>
377-
/// <param name="objectish">The source objectish to push.</param>
378-
/// <param name="destinationSpec">The reference to update on the remote.</param>
379-
/// <param name="pushOptions"><see cref="PushOptions"/> controlling push behavior</param>
380-
public virtual void Push(
381-
Remote remote,
382-
string objectish,
383-
string destinationSpec,
384-
PushOptions pushOptions)
385-
{
386-
Ensure.ArgumentNotNull(objectish, "objectish");
387-
Ensure.ArgumentNotNullOrEmptyString(destinationSpec, "destinationSpec");
388-
389-
Push(remote, string.Format(CultureInfo.InvariantCulture,
390-
"{0}:{1}", objectish, destinationSpec), pushOptions);
391-
}
392-
393-
/// <summary>
394-
/// Push specified reference to the <see cref="Remote"/>.
395-
/// </summary>
396-
/// <param name="remote">The <see cref="Remote"/> to push to.</param>
397-
/// <param name="pushRefSpec">The pushRefSpec to push.</param>
398-
public virtual void Push(
399-
Remote remote,
400-
string pushRefSpec)
401-
{
402-
Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, "pushRefSpec");
403-
404-
Push(remote, new[] { pushRefSpec });
405-
}
406-
/// <summary>
407-
/// Push specified reference to the <see cref="Remote"/>.
408-
/// </summary>
409-
/// <param name="remote">The <see cref="Remote"/> to push to.</param>
410-
/// <param name="pushRefSpec">The pushRefSpec to push.</param>
411-
/// <param name="pushOptions"><see cref="PushOptions"/> controlling push behavior</param>
412-
public virtual void Push(
413-
Remote remote,
414-
string pushRefSpec,
415-
PushOptions pushOptions)
416-
{
417-
Ensure.ArgumentNotNullOrEmptyString(pushRefSpec, "pushRefSpec");
418-
419-
Push(remote, new[] { pushRefSpec }, pushOptions);
420-
}
421-
422-
/// <summary>
423-
/// Push specified references to the <see cref="Remote"/>.
424-
/// </summary>
425-
/// <param name="remote">The <see cref="Remote"/> to push to.</param>
426-
/// <param name="pushRefSpecs">The pushRefSpecs to push.</param>
427-
public virtual void Push(
428-
Remote remote,
429-
IEnumerable<string> pushRefSpecs)
430-
{
431-
Push(remote, pushRefSpecs, null);
432-
}
433-
434222
/// <summary>
435223
/// Push specified references to the <see cref="Remote"/>.
436224
/// </summary>
@@ -493,7 +281,7 @@ public virtual MergeResult Pull(Signature merger, PullOptions options)
493281
throw new LibGit2SharpException("No upstream remote for the current branch.");
494282
}
495283

496-
Fetch(currentBranch.Remote, options.FetchOptions);
284+
Fetch(currentBranch.Remote, options.FetchOptions, null);
497285
return repository.MergeFetchedRefs(merger, options.MergeOptions);
498286
}
499287

0 commit comments

Comments
 (0)