Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14b3c1a

Browse files
shiftkeynulltoken
authored andcommitted
Drop optional parameters in RepositoryExtensions
1 parent 494de48 commit 14b3c1a

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

LibGit2Sharp/RepositoryExtensions.cs

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,24 @@ public static Branch CreateBranch(this IRepository repository, string branchName
152152
}
153153

154154
/// <summary>
155-
/// Sets the current <see cref="Repository.Head"/> to the specified commit and optionally resets the <see cref="Index"/> and
155+
/// Sets the current <see cref="Repository.Head"/> and resets the <see cref="Index"/> and
156+
/// the content of the working tree to match.
157+
/// </summary>
158+
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
159+
/// <param name="resetMode">Flavor of reset operation to perform.</param>
160+
public static void Reset(this IRepository repository, ResetMode resetMode)
161+
{
162+
repository.Reset(resetMode, "HEAD");
163+
}
164+
165+
/// <summary>
166+
/// Sets the current <see cref="Repository.Head"/> to the specified commitish and optionally resets the <see cref="Index"/> and
156167
/// the content of the working tree to match.
157168
/// </summary>
158169
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
159170
/// <param name="resetMode">Flavor of reset operation to perform.</param>
160171
/// <param name="committish">A revparse spec for the target commit object.</param>
161-
public static void Reset(this IRepository repository, ResetMode resetMode, string committish = "HEAD")
172+
public static void Reset(this IRepository repository, ResetMode resetMode, string committish)
162173
{
163174
Ensure.ArgumentNotNullOrEmptyString(committish, "committish");
164175

@@ -199,6 +210,20 @@ private static Commit LookUpCommit(IRepository repository, string committish)
199210
return obj.DereferenceToCommit(true);
200211
}
201212

213+
/// <summary>
214+
/// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository.
215+
/// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit.
216+
/// Once the commit is created, the <see cref="Repository.Head"/> will move forward to point at it.
217+
/// <para>Both the Author and Committer will be guessed from the Git configuration. An exception will be raised if no configuration is reachable.</para>
218+
/// </summary>
219+
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
220+
/// <param name="message">The description of why a change was made to the repository.</param>
221+
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
222+
public static Commit Commit(this IRepository repository, string message)
223+
{
224+
return repository.Commit(message, (CommitOptions)null);
225+
}
226+
202227
/// <summary>
203228
/// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository.
204229
/// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit.
@@ -209,13 +234,29 @@ private static Commit LookUpCommit(IRepository repository, string committish)
209234
/// <param name="message">The description of why a change was made to the repository.</param>
210235
/// <param name="options">The <see cref="CommitOptions"/> that specify the commit behavior.</param>
211236
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
212-
public static Commit Commit(this IRepository repository, string message, CommitOptions options = null)
237+
public static Commit Commit(this IRepository repository, string message, CommitOptions options)
213238
{
214239
Signature author = repository.Config.BuildSignature(DateTimeOffset.Now, true);
215240

216241
return repository.Commit(message, author, options);
217242
}
218243

244+
/// <summary>
245+
/// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository.
246+
/// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit.
247+
/// Once the commit is created, the <see cref="Repository.Head"/> will move forward to point at it.
248+
/// <para>The Committer will be guessed from the Git configuration. An exception will be raised if no configuration is reachable.</para>
249+
/// </summary>
250+
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
251+
/// <param name="author">The <see cref="Signature"/> of who made the change.</param>
252+
/// <param name="message">The description of why a change was made to the repository.</param>
253+
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
254+
public static Commit Commit(this IRepository repository, string message, Signature author)
255+
{
256+
return repository.Commit(message, author, (CommitOptions)null);
257+
}
258+
259+
219260
/// <summary>
220261
/// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="LibGit2Sharp.Commit"/> into the repository.
221262
/// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit.
@@ -227,20 +268,30 @@ public static Commit Commit(this IRepository repository, string message, CommitO
227268
/// <param name="message">The description of why a change was made to the repository.</param>
228269
/// <param name="options">The <see cref="CommitOptions"/> that specify the commit behavior.</param>
229270
/// <returns>The generated <see cref="LibGit2Sharp.Commit"/>.</returns>
230-
public static Commit Commit(this IRepository repository, string message, Signature author, CommitOptions options = null)
271+
public static Commit Commit(this IRepository repository, string message, Signature author, CommitOptions options)
231272
{
232273
Signature committer = repository.Config.BuildSignature(DateTimeOffset.Now, true);
233274

234275
return repository.Commit(message, author, committer, options);
235276
}
236277

278+
/// <summary>
279+
/// Fetch from the specified remote.
280+
/// </summary>
281+
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
282+
/// <param name="remoteName">The name of the <see cref="Remote"/> to fetch from.</param>
283+
public static void Fetch(this IRepository repository, string remoteName)
284+
{
285+
repository.Fetch(remoteName, null);
286+
}
287+
237288
/// <summary>
238289
/// Fetch from the specified remote.
239290
/// </summary>
240291
/// <param name="repository">The <see cref="Repository"/> being worked with.</param>
241292
/// <param name="remoteName">The name of the <see cref="Remote"/> to fetch from.</param>
242293
/// <param name="options"><see cref="FetchOptions"/> controlling fetch behavior</param>
243-
public static void Fetch(this IRepository repository, string remoteName, FetchOptions options = null)
294+
public static void Fetch(this IRepository repository, string remoteName, FetchOptions options)
244295
{
245296
Ensure.ArgumentNotNull(repository, "repository");
246297
Ensure.ArgumentNotNullOrEmptyString(remoteName, "remoteName");

0 commit comments

Comments
 (0)