diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-02-25 22:12:02 +0400 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2012-02-27 13:33:26 +0400 |
commit | c37d818160608e337a7acaf7fbe11a55f124b8e8 (patch) | |
tree | 0209793232f6be5443dcf9d304cfd64fd37fa8bd /LibGit2Sharp/RemoteCollection.cs | |
parent | 2194806398eec51c5a9dc14dd67a6c4934e2f340 (diff) |
Add RemoteCollection.Create()
Diffstat (limited to 'LibGit2Sharp/RemoteCollection.cs')
-rw-r--r-- | LibGit2Sharp/RemoteCollection.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/LibGit2Sharp/RemoteCollection.cs b/LibGit2Sharp/RemoteCollection.cs index e4c23688..d2950b6f 100644 --- a/LibGit2Sharp/RemoteCollection.cs +++ b/LibGit2Sharp/RemoteCollection.cs @@ -71,5 +71,29 @@ namespace LibGit2Sharp { return GetEnumerator(); } + + /// <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> + /// <returns>A new <see cref = "Remote" />.</returns> + public Remote Create(string name, string url) + { + Ensure.ArgumentNotNull(name, "name"); + Ensure.ArgumentNotNull(url, "url"); + + RemoteSafeHandle handle; + int res = NativeMethods.git_remote_new(out handle, repository.Handle, url, name); + Ensure.Success(res); + + using (handle) + { + res = NativeMethods.git_remote_save(handle); + Ensure.Success(res); + + return Remote.CreateFromPtr(handle); + } + } } } |