Skip to content

Commit bce3f4c

Browse files
shiftkeynulltoken
authored andcommitted
Drop optional parameters in ReferenceCollectionExtensions.cs
1 parent d16fbec commit bce3f4c

File tree

1 file changed

+70
-3
lines changed

1 file changed

+70
-3
lines changed

LibGit2Sharp/ReferenceCollectionExtensions.cs

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ private static RefState TryResolveReference(out Reference reference, ReferenceCo
3232
return reference != null ? RefState.Exists : RefState.DoesNotExistButLooksValid;
3333
}
3434

35+
/// <summary>
36+
/// Creates a direct or symbolic reference with the specified name and target
37+
/// </summary>
38+
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
39+
/// <param name="name">The name of the reference to create.</param>
40+
/// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
41+
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
42+
/// <returns>A new <see cref="Reference"/>.</returns>
43+
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish,
44+
string logMessage)
45+
{
46+
return refsColl.Add(name, canonicalRefNameOrObjectish, logMessage, false);
47+
}
48+
3549
/// <summary>
3650
/// Creates a direct or symbolic reference with the specified name and target
3751
/// </summary>
@@ -41,7 +55,7 @@ private static RefState TryResolveReference(out Reference reference, ReferenceCo
4155
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
4256
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
4357
/// <returns>A new <see cref="Reference"/>.</returns>
44-
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, string logMessage, bool allowOverwrite = false)
58+
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, string logMessage, bool allowOverwrite)
4559
{
4660
Ensure.ArgumentNotNullOrEmptyString(name, "name");
4761
Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish");
@@ -77,6 +91,19 @@ public static Reference Add(this ReferenceCollection refsColl, string name, stri
7791
return refsColl.Add(name, gitObject.Id, logMessage, allowOverwrite);
7892
}
7993

94+
95+
/// <summary>
96+
/// Creates a direct or symbolic reference with the specified name and target
97+
/// </summary>
98+
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
99+
/// <param name="name">The name of the reference to create.</param>
100+
/// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
101+
/// <returns>A new <see cref="Reference"/>.</returns>
102+
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish)
103+
{
104+
return Add(refsColl, name, canonicalRefNameOrObjectish, null, false);
105+
}
106+
80107
/// <summary>
81108
/// Creates a direct or symbolic reference with the specified name and target
82109
/// </summary>
@@ -85,7 +112,7 @@ public static Reference Add(this ReferenceCollection refsColl, string name, stri
85112
/// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
86113
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
87114
/// <returns>A new <see cref="Reference"/>.</returns>
88-
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, bool allowOverwrite = false)
115+
public static Reference Add(this ReferenceCollection refsColl, string name, string canonicalRefNameOrObjectish, bool allowOverwrite)
89116
{
90117
return Add(refsColl, name, canonicalRefNameOrObjectish, null, allowOverwrite);
91118
}
@@ -122,6 +149,46 @@ public static Reference UpdateTarget(this ReferenceCollection refsColl, Referenc
122149
return UpdateTarget(refsColl, directRef, objectish, null);
123150
}
124151

152+
/// <summary>
153+
/// Rename an existing reference with a new name
154+
/// </summary>
155+
/// <param name="currentName">The canonical name of the reference to rename.</param>
156+
/// <param name="newName">The new canonical name.</param>
157+
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
158+
/// <returns>A new <see cref="Reference"/>.</returns>
159+
public static Reference Rename(this ReferenceCollection refsColl, string currentName, string newName)
160+
{
161+
return refsColl.Rename(currentName, newName, null, false);
162+
}
163+
164+
/// <summary>
165+
/// Rename an existing reference with a new name
166+
/// </summary>
167+
/// <param name="currentName">The canonical name of the reference to rename.</param>
168+
/// <param name="newName">The new canonical name.</param>
169+
/// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
170+
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
171+
/// <returns>A new <see cref="Reference"/>.</returns>
172+
public static Reference Rename(this ReferenceCollection refsColl, string currentName, string newName,
173+
bool allowOverwrite)
174+
{
175+
return refsColl.Rename(currentName, newName, null, allowOverwrite);
176+
}
177+
178+
/// <summary>
179+
/// Rename an existing reference with a new name
180+
/// </summary>
181+
/// <param name="currentName">The canonical name of the reference to rename.</param>
182+
/// <param name="newName">The new canonical name.</param>
183+
/// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/></param>
184+
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
185+
/// <returns>A new <see cref="Reference"/>.</returns>
186+
public static Reference Rename(this ReferenceCollection refsColl, string currentName, string newName,
187+
string logMessage)
188+
{
189+
return refsColl.Rename(currentName, newName, logMessage, false);
190+
}
191+
125192
/// <summary>
126193
/// Rename an existing reference with a new name
127194
/// </summary>
@@ -132,7 +199,7 @@ public static Reference UpdateTarget(this ReferenceCollection refsColl, Referenc
132199
/// <param name="refsColl">The <see cref="ReferenceCollection"/> being worked with.</param>
133200
/// <returns>A new <see cref="Reference"/>.</returns>
134201
public static Reference Rename(this ReferenceCollection refsColl, string currentName, string newName,
135-
string logMessage = null, bool allowOverwrite = false)
202+
string logMessage, bool allowOverwrite)
136203
{
137204
Ensure.ArgumentNotNullOrEmptyString(currentName, "currentName");
138205

0 commit comments

Comments
 (0)