8000 Move BuildSignatureFromGlobalConfiguration() to Configuration · leoniDEV/libgit2sharp@4d92ed4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d92ed4

Browse files
committed
Move BuildSignatureFromGlobalConfiguration() to Configuration
1 parent 902ed7d commit 4d92ed4

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

LibGit2Sharp/Configuration.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,18 @@ private IEnumerable<ConfigurationEntry<string>> BuildConfigEntries()
287287
(ConfigurationLevel)entry.level);
288288
});
289289
}
290+
291+
internal Signature BuildSignatureFromGlobalConfiguration(DateTimeOffset now)
292+
{
293+
var name = Get<string>("user.name");
294+
var email = Get<string>("user.email");
295+
296+
if ((name == null) || (email == null))
297+
{
298+
throw new LibGit2SharpException("Can not find Name and Email settings of the current user in Git configuration.");
299+
}
300+
301+
return new Signature(name.Value, email.Value, now);
302+
}
290303
}
291304
}

LibGit2Sharp/RepositoryExtensions.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private static Commit LookUpCommit(IRepository repository, string committish)
173173
/// <returns>The generated <see cref = "LibGit2Sharp.Commit" />.</returns>
174174
public static Commit Commit(this IRepository repository, string message, bool amendPreviousCommit = false)
175175
{
176-
Signature author = BuildSignatureFromGlobalConfiguration(repository, DateTimeOffset.Now);
176+
Signature author = repository.Config.BuildSignatureFromGlobalConfiguration(DateTimeOffset.Now);
177177

178178
return repository.Commit(message, author, amendPreviousCommit);
179179
}
@@ -191,7 +191,7 @@ public static Commit Commit(this IRepository repository, string message, bool am
191191
/// <returns>The generated <see cref = "LibGit2Sharp.Commit" />.</returns>
192192
public static Commit Commit(this IRepository repository, string message, Signature author, bool amendPreviousCommit = false)
193193
{
194-
Signature committer = BuildSignatureFromGlobalConfiguration(repository, DateTimeOffset.Now);
194+
Signature committer = repository.Config.BuildSignatureFromGlobalConfiguration(DateTimeOffset.Now);
195195

196196
return repository.Commit(message, author, committer, amendPreviousCommit);
197197
}
@@ -224,19 +224,6 @@ public static void Fetch(this IRepository repository, string remoteName,
224224
onTransferProgress, credentials);
225225
}
226226

227-
private static Signature BuildSignatureFromGlobalConfiguration(IRepository repository, DateTimeOffset now)
228-
{
229-
var name = repository.Config.Get<string>("user.name");
230-
var email = repository.Config.Get<string>("user.email");
231-
232-
if ((name == null) || (email == null))
233-
{
234-
throw new LibGit2SharpException("Can not find Name and Email settings of the current user in Git configuration.") 6474 ;
235-
}
236-
237-
return new Signature(name.Value, email.Value, now);
238-
}
239-
240227
/// <summary>
241228
/// Checkout the specified <see cref = "Branch" />, reference or SHA.
242229
/// </summary>

0 commit comments

Comments
 (0)
0