private IEnumerable <string> GetPushRefSpecs() { using (RemoteHandle remoteHandle = Proxy.git_remote_lookup(repo.Handle, remoteName, true)) { return(Proxy.git_remote_get_push_refspecs(remoteHandle)); } }
internal Remote(RemoteHandle handle, Repository repository) { this.repository = repository; this.handle = handle; refSpecs = new RefSpecCollection(this, handle); repository.RegisterForCleanup(this); }
/// <summary> /// Push specified references to the <see cref="Remote"/>. /// </summary> /// <param name="remote">The <see cref="Remote"/> to push to.</param> /// <param name="pushRefSpecs">The pushRefSpecs to push.</param> /// <param name="pushOptions"><see cref="PushOptions"/> controlling push behavior</param> public virtual void Push(Remote remote, IEnumerable <string> pushRefSpecs, PushOptions pushOptions) { Ensure.ArgumentNotNull(remote, "remote"); Ensure.ArgumentNotNull(pushRefSpecs, "pushRefSpecs"); // Return early if there is nothing to push. if (!pushRefSpecs.Any()) { return; } if (pushOptions == null) { pushOptions = new PushOptions(); } // Load the remote. using (RemoteHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, remote.Name, true)) { var callbacks = new RemoteCallbacks(pushOptions); GitRemoteCallbacks gitCallbacks = callbacks.GenerateCallbacks(); Proxy.git_remote_push(remoteHandle, pushRefSpecs, new GitPushOptions() { PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism, RemoteCallbacks = gitCallbacks, ProxyOptions = new GitProxyOptions { Version = 1 }, CustomHeaders = GitStrArrayManaged.BuildFrom(pushOptions.CustomHeaders), }); } }
/// <summary> /// Transform a reference to its source reference using the <see cref="Remote"/>'s default fetchspec. /// </summary> /// <param name="reference">The reference to transform.</param> /// <returns>The transformed reference.</returns> internal unsafe string FetchSpecTransformToSource(string reference) { using (RemoteHandle remoteHandle = Proxy.git_remote_lookup(repository.Handle, Name, true)) { git_refspec *fetchSpecPtr = Proxy.git_remote_get_refspec(remoteHandle, 0); return(Proxy.git_refspec_rtransform(new IntPtr(fetchSpecPtr), reference)); } }
internal Remote RemoteForName(string name, bool shouldThrowIfNotFound = true) { Ensure.ArgumentNotNull(name, "name"); RemoteHandle handle = Proxy.git_remote_lookup(repository.Handle, name, shouldThrowIfNotFound); return(handle == null ? null : new Remote(handle, this.repository)); }
internal RefSpecCollection(Remote remote, RemoteHandle handle) { Ensure.ArgumentNotNull(handle, "handle"); this.remote = remote; this.handle = handle; refspecs = new Lazy <IList <RefSpec> >(() => RetrieveRefSpecs(remote, handle)); }
/// <summary> /// Creates a <see cref="Remote"/> with the specified name and for the repository at the specified location. /// <para> /// A default fetch refspec will be added for this remote. /// </para> /// </summary> /// <param name="name">The name of the remote to create.</param> /// <param name="url">The location of the repository.</param> /// <returns>A new <see cref="Remote"/>.</returns> public virtual Remote Add(string name, string url) { Ensure.ArgumentNotNull(name, "name"); Ensure.ArgumentNotNull(url, "url"); RemoteHandle handle = Proxy.git_remote_create(repository.Handle, name, url); return(new Remote(handle, this.repository)); }
/// <summary> /// Creates a <see cref="Remote"/> with the specified name and for the repository at the specified location. /// </summary> /// <param name="name">The name of the remote to create.</param> /// <param name="url">The location of the repository.</param> /// <param name="fetchRefSpec">The refSpec to be used when fetching from this remote.</param> /// <returns>A new <see cref="Remote"/>.</returns> public virtual Remote Add(string name, string url, string fetchRefSpec) { Ensure.ArgumentNotNull(name, "name"); Ensure.ArgumentNotNull(url, "url"); Ensure.ArgumentNotNull(fetchRefSpec, "fetchRefSpec"); RemoteHandle handle = Proxy.git_remote_create_with_fetchspec(repository.Handle, name, url, fetchRefSpec); return(new Remote(handle, this.repository)); }
static RemoteHandle BuildRemoteHandle(RepositoryHandle repoHandle, string url) { Debug.Assert(repoHandle != null && !repoHandle.IsNull); Debug.Assert(url != null); RemoteHandle remoteHandle = Proxy.git_remote_create_anonymous(repoHandle, url); Debug.Assert(remoteHandle != null && !(remoteHandle.IsNull)); return(remoteHandle); }
static unsafe IList <RefSpec> RetrieveRefSpecs(Remote remote, RemoteHandle remoteHandle) { int count = Proxy.git_remote_refspec_count(remoteHandle); List <RefSpec> refSpecs = new List <RefSpec>(); for (int i = 0; i < count; i++) { refSpecs.Add(new RefSpec(remote, Proxy.git_remote_get_refspec(remoteHandle, i))); } return(refSpecs); }
private static RemoteHandle RemoteFromNameOrUrl(RepositoryHandle repoHandle, string remote) { RemoteHandle handle = null; handle = Proxy.git_remote_lookup(repoHandle, remote, false); // If that wasn't the name of a remote, let's use it as a url if (handle == null) { handle = Proxy.git_remote_create_anonymous(repoHandle, remote); } return(handle); }
private IEnumerable <Reference> ListReferencesInternal(string url, CredentialsHandler credentialsProvider) { using (RemoteHandle remoteHandle = BuildRemoteHandle(repository.Handle, url)) { GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks { version = 1 }; if (credentialsProvider != null) { var callbacks = new RemoteCallbacks(credentialsProvider); gitCallbacks = callbacks.GenerateCallbacks(); } Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch, ref gitCallbacks); return(Proxy.git_remote_ls(repository, remoteHandle)); } }