diff options
Diffstat (limited to 'LibGit2Sharp/BranchCollectionExtensions.cs')
-rw-r--r-- | LibGit2Sharp/BranchCollectionExtensions.cs | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/LibGit2Sharp/BranchCollectionExtensions.cs b/LibGit2Sharp/BranchCollectionExtensions.cs index cea02c7a..68b15dec 100644 --- a/LibGit2Sharp/BranchCollectionExtensions.cs +++ b/LibGit2Sharp/BranchCollectionExtensions.cs @@ -13,15 +13,36 @@ namespace LibGit2Sharp /// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param> /// <param name="name">The name of the branch.</param> /// <param name="commit">The target commit.</param> + /// <returns>A new <see cref="Branch"/>.</returns> + public static Branch Add(this BranchCollection branches, string name, Commit commit) + { + return branches.Add(name, commit, false); + } + + /// <summary> + /// Create a new local branch with the specified name + /// </summary> + /// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param> + /// <param name="name">The name of the branch.</param> + /// <param name="commit">The target commit.</param> /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param> /// <returns>A new <see cref="Branch"/>.</returns> - public static Branch Add(this BranchCollection branches, string name, Commit commit, bool allowOverwrite = false) + public static Branch Add(this BranchCollection branches, string name, Commit commit, bool allowOverwrite) { Ensure.ArgumentNotNull(commit, "commit"); return branches.Add(name, commit.Sha, allowOverwrite); } + /// <summary> + /// Deletes the branch with the specified name. + /// </summary> + /// <param name="name">The name of the branch to delete.</param> + /// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param> + public static void Remove(this BranchCollection branches, string name) + { + branches.Remove(name, false); + } /// <summary> /// Deletes the branch with the specified name. @@ -29,7 +50,7 @@ namespace LibGit2Sharp /// <param name="name">The name of the branch to delete.</param> /// <param name="isRemote">True if the provided <paramref name="name"/> is the name of a remote branch, false otherwise.</param> /// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param> - public static void Remove(this BranchCollection branches, string name, bool isRemote = false) + public static void Remove(this BranchCollection branches, string name, bool isRemote) { Ensure.ArgumentNotNullOrEmptyString(name, "name"); @@ -50,10 +71,22 @@ namespace LibGit2Sharp /// </summary> /// <param name="currentName">The current branch name.</param> /// <param name="newName">The new name the existing branch should bear.</param> + /// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param> + /// <returns>A new <see cref="Branch"/>.</returns> + public static Branch Rename(this BranchCollection branches, string currentName, string newName) + { + return branches.Rename(currentName, newName, false); + } + + /// <summary> + /// Rename an existing local branch, using the default reflog message + /// </summary> + /// <param name="currentName">The current branch name.</param> + /// <param name="newName">The new name the existing branch should bear.</param> /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param> /// <param name="branches">The <see cref="BranchCollection"/> being worked with.</param> /// <returns>A new <see cref="Branch"/>.</returns> - public static Branch Rename(this BranchCollection branches, string currentName, string newName, bool allowOverwrite = false) + public static Branch Rename(this BranchCollection branches, string currentName, string newName, bool allowOverwrite) { Ensure.ArgumentNotNullOrEmptyString(currentName, "currentName"); Ensure.ArgumentNotNullOrEmptyString(newName, "newName"); |