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

Skip to content

Commit dd15de9

Browse files
tclemnulltoken
authored andcommitted
Rename LibGit2Exception to LibGit2SharpException
1 parent 5f55b57 commit dd15de9

22 files changed

+135
-101
lines changed

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ public void CreatingABranchFromANonCommitObjectThrows()
125125
using (var repo = new Repository(BareTestRepoPath))
126126
{
127127
const string name = "sorry-dude-i-do-not-do-blobs-nor-trees";
128-
Assert.Throws<LibGit2Exception>(() => repo.CreateBranch(name, "refs/tags/point_to_blob"));
129-
Assert.Throws<LibGit2Exception>(() => repo.CreateBranch(name, "53fc32d"));
130-
Assert.Throws<LibGit2Exception>(() => repo.CreateBranch(name, "0266163"));
128+
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "refs/tags/point_to_blob"));
129+
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "53fc32d"));
130+
Assert.Throws<LibGit2SharpException>(() => repo.CreateBranch(name, "0266163"));
131131
}
132132
}
133133

@@ -136,7 +136,7 @@ public void CreatingBranchWithUnknownNamedTargetThrows()
136136
{
137137
using (var repo = new Repository(BareTestRepoPath))
138138
{
139-
Assert.Throws<LibGit2Exception>(() => repo.Branches.Create("my_new_branch", "my_old_branch"));
139+
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("my_new_branch", "my_old_branch"));
140140
}
141141
}
142142

@@ -145,8 +145,8 @@ public void CreatingBranchWithUnknownShaTargetThrows()
145145
{
146146
using (var repo = new Repository(BareTestRepoPath))
147147
{
148-
Assert.Throws<LibGit2Exception>(() => repo.Branches.Create("my_new_branch", Constants.UnknownSha));
149-
Assert.Throws<LibGit2Exception>(() => repo.Branches.Create("my_new_branch", Constants.UnknownSha.Substring(0, 7)));
148+
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("my_new_branch", Constants.UnknownSha));
149+
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("my_new_branch", Constants.UnknownSha.Substring(0, 7)));
150150
}
151151
}
152152

@@ -155,7 +155,7 @@ public void CreatingABranchPointingAtANonCanonicalReferenceThrows()
155155
{
156156
using (var repo = new Repository(BareTestRepoPath))
157157
{
158-
Assert.Throws<LibGit2Exception>(() => repo.Branches.Create("nocanonicaltarget", "br2"));
158+
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Create("nocanonicaltarget", "br2"));
159159
}
160160
}
161161

@@ -414,7 +414,7 @@ public void CheckingOutANonExistingBranchThrows()
414414
{
415415
using (var repo = new Repository(BareTestRepoPath))
416416
{
417-
Assert.Throws<LibGit2Exception>(() => repo.Checkout("i-do-not-exist"));
417+
Assert.Throws<LibGit2SharpException>(() => repo.Checkout("i-do-not-exist"));
418418
}
419419
}
420420

@@ -468,7 +468,7 @@ public void DeletingABranchWhichIsTheCurrentHeadThrows()
468468
{
469469
using (var repo = new Repository(BareTestRepoPath))
470470
{
471-
Assert.Throws<LibGit2Exception>(() => repo.Branches.Delete(repo.Head.Name));
471+
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Delete(repo.Head.Name));
472472
}
473473
}
474474

@@ -545,7 +545,7 @@ public void BlindlyMovingABranchOverAnExistingOneThrows()
545545
{
546546
using (var repo = new Repository(BareTestRepoPath))
547547
{
548-
Assert.Throws<LibGit2Exception>(() => repo.Branches.Move("br2", "test"));
548+
Assert.Throws<LibGit2SharpException>(() => repo.Branches.Move("br2", "test"));
549549
}
550550
}
551551

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public void QueryingTheCommitHistoryWithUnknownShaOrInvalidEntryPointThrows()
9696
{
9797
using (var repo = new Repository(BareTestRepoPath))
9898
{
99-
Assert.Throws<LibGit2Exception>(() => repo.Commits.QueryBy(new Filter { Since = Constants.UnknownSha }).Count());
100-
Assert.Throws<LibGit2Exception>(() => repo.Commits.QueryBy(new Filter { Since = "refs/heads/deadbeef" }).Count());
99+
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = Constants.UnknownSha }).Count());
100+
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = "refs/heads/deadbeef" }).Count());
101101
Assert.Throws<ArgumentNullException>(() => repo.Commits.QueryBy(new Filter { Since = null }).Count());
102102
}
103103
}
@@ -110,8 +110,8 @@ public void QueryingTheCommitHistoryFromACorruptedReferenceThrows()
110110
{
111111
CreateCorruptedDeadBeefHead(repo.Info.Path);
112112

113-
Assert.Throws<LibGit2Exception>(() => repo.Commits.QueryBy(new Filter { Since = repo.Branches["deadbeef"] }).Count());
114-
Assert.Throws<LibGit2Exception>(() => repo.Commits.QueryBy(new Filter { Since = repo.Refs["refs/heads/deadbeef"] }).Count());
113+
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = repo.Branches["deadbeef"] }).Count());
114+
Assert.Throws<LibGit2SharpException>(() => repo.Commits.QueryBy(new Filter { Since = repo.Refs["refs/heads/deadbeef"] }).Count());
115115
}
116116
}
117117

@@ -647,7 +647,7 @@ public void CanNotAmendAnEmptyRepository()
647647

648648
using (Repository repo = Repository.Init(scd.DirectoryPath))
649649
{
650-
Assert.Throws<LibGit2Exception>(() => repo.Commit("I can not amend anything !:(", DummySignature, DummySignature, true));
650+
Assert.Throws<LibGit2SharpException>(() => repo.Commit("I can not amend anything !:(", DummySignature, DummySignature, true));
651651
}
652652
}
653653

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void SettingLocalConfigurationOutsideAReposThrows()
220220
{
221221
using (var config = new Configuration())
222222
{
223-
Assert.Throws<LibGit2Exception>(() => config.Set("unittests.intsetting", 3));
223+
Assert.Throws<LibGit2SharpException>(() => config.Set("unittests.intsetting", 3));
224224
}
225225
}
226226

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void StagingAnUnknownFileThrows(string relativePath, FileStatus status)
140140
Assert.Null(repo.Index[relativePath]);
141141
Assert.Equal(status, repo.Index.RetrieveStatus(relativePath));
142142

143-
Assert.Throws<LibGit2Exception>(() => repo.Index.Stage(relativePath));
143+
Assert.Throws<LibGit2SharpException>(() => repo.Index.Stage(relativePath));
144144
}
145145
}
146146

@@ -457,7 +457,7 @@ private static void InvalidMoveUseCases(string sourcePath, FileStatus sourceStat
457457
foreach (var destPath in destPaths)
458458
{
459459
string path = destPath;
460-
Assert.Throws<LibGit2Exception>(() => repo.Index.Move(sourcePath, path));
460+
Assert.Throws<LibGit2SharpException>(() => repo.Index.Move(sourcePath, path));
461461
}
462462
}
463463
}
@@ -493,7 +493,7 @@ public void RemovingAInvalidFileThrows(string filepath)
493493
{
494494
using (var repo = new Repository(StandardTestRepoPath))
495495
{
496-
Assert.Throws<LibGit2Exception>(() => repo.Index.Remove(filepath));
496+
Assert.Throws<LibGit2SharpException>(() => repo.Index.Remove(filepath));
497497
}
498498
}
499499

LibGit2Sharp.Tests/ReferenceFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void BlindlyCreatingADirectReferenceOverAnExistingOneThrows()
5858
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
5959
using (var repo = new Repository(path.RepositoryPath))
6060
{
61-
Assert.Throws<LibGit2Exception>(() => repo.Refs.Create("refs/heads/master", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
61+
Assert.Throws<LibGit2SharpException>(() => repo.Refs.Create("refs/heads/master", "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
6262
}
6363
}
6464

@@ -68,7 +68,7 @@ public void BlindlyCreatingASymbolicReferenceOverAnExistingOneThrows()
6868
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
6969
using (var repo = new Repository(path.RepositoryPath))
7070
{
71-
Assert.Throws<LibGit2Exception>(() => repo.Refs.Create("HEAD", "refs/head/br2"));
71+
Assert.Throws<LibGit2SharpException>(() => repo.Refs.Create("HEAD", "refs/head/br2"));
7272
}
7373
}
7474

@@ -446,7 +446,7 @@ public void MovingANonExistingReferenceThrows()
446446
{
447447
using (var repo = new Repository(BareTestRepoPath))
448448
{
449-
Assert.Throws<LibGit2Exception>(() => repo.Refs.Move("refs/tags/i-am-void", "refs/atic/tagtest"));
449+
Assert.Throws<LibGit2SharpException>(() => repo.Refs.Move("refs/tags/i-am-void", "refs/atic/tagtest"));
450450
}
451451
}
452452

@@ -471,7 +471,7 @@ public void BlindlyOverwritingAExistingReferenceThrows()
471471
{
472472
using (var repo = new Repository(BareTestRepoPath))
473473
{
474-
Assert.Throws<LibGit2Exception>(() => repo.Refs.Move("refs/heads/packed", "refs/heads/br2"));
474+
Assert.Throws<LibGit2SharpException>(() => repo.Refs.Move("refs/heads/packed", "refs/heads/br2"));
475475
}
476476
}
477477

LibGit2Sharp.Tests/RepositoryFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void AccessingTheIndexInABareRepoThrows()
3434
{
3535
using (var repo = new Repository(BareTestRepoPath))
3636
{
37-
Assert.Throws<LibGit2Exception>(() => repo.Index);
37+
Assert.Throws<LibGit2SharpException>(() => repo.Index);
3838
}
3939
}
4040

@@ -170,7 +170,7 @@ public void CanOpenRepository()
170170
[Fact]
171171
public void OpeningNonExistentRepoThrows()
172172
{
173-
Assert.Throws<LibGit2Exception>(() => { new Repository("a_bad_path"); });
173+
Assert.Throws<LibGit2SharpException>(() => { new Repository("a_bad_path"); });
174174
}
175175

176176
[Fact]

LibGit2Sharp.Tests/ResetFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void ResetANewlyInitializedRepositoryThrows(bool isBare)
1717

1818
using (var repo = Repository.Init(scd.DirectoryPath, isBare))
1919
{
20-
Assert.Throws<LibGit2Exception>(() => repo.Reset(ResetOptions.Soft, repo.Head.CanonicalName));
20+
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetOptions.Soft, repo.Head.CanonicalName));
2121
}
2222
}
2323

@@ -54,7 +54,7 @@ public void ResettingWithBadParamsThrows()
5454
{
5555
Assert.Throws<ArgumentNullException>(() => repo.Reset(ResetOptions.Soft, null));
5656
Assert.Throws<ArgumentException>(() => repo.Reset(ResetOptions.Soft, ""));
57-
Assert.Throws<LibGit2Exception>(() => repo.Reset(ResetOptions.Soft, Constants.UnknownSha));
57+
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetOptions.Soft, Constants.UnknownSha));
5858
}
5959
}
6060

@@ -149,7 +149,7 @@ public void MixedResetInABareRepositoryThrows()
149149
{
150150
using (var repo = new Repository(BareTestRepoPath))
151151
{
152-
Assert.Throws<LibGit2Exception>(() => repo.Reset(ResetOptions.Mixed, repo.Head.Tip.Sha));
152+
Assert.Throws<LibGit2SharpException>(() => repo.Reset(ResetOptions.Mixed, repo.Head.Tip.Sha));
153153
}
154154
}
155155
}

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void RetrievingTheStatusOfADirectoryThrows()
2323
{
2424
using (var repo = new Repository(StandardTestRepoPath))
2525
{
26-
Assert.Throws<LibGit2Exception>(() => { FileStatus status = repo.Index.RetrieveStatus("1"); });
26+
Assert.Throws<LibGit2SharpException>(() => { FileStatus status = repo.Index.RetrieveStatus("1"); });
2727
}
2828
}
2929

LibGit2Sharp.Tests/TagFixture.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public void CreatingATagWithNameMatchingAnAlreadyExistingReferenceHierarchyThrow
9595
using (var repo = new Repository(path.RepositoryPath))
9696
{
9797
repo.ApplyTag("i/am/deep");
98-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("i/am/deep/rooted"));
99-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("i/am"));
98+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("i/am/deep/rooted"));
99+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("i/am"));
100100
}
101101
}
102102

@@ -175,7 +175,7 @@ public void CreatingATagInAEmptyRepositoryThrows()
175175

176176
using (var repo = Repository.Init(scd.DirectoryPath))
177177
{
178-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("mynotag"));
178+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mynotag"));
179179
}
180180
}
181181

@@ -187,7 +187,7 @@ public void CreatingATagForHeadInAEmptyRepositoryThrows()
187187

188188
using (var repo = Repository.Init(scd.DirectoryPath))
189189
{
190-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("mytaghead", "HEAD"));
190+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mytaghead", "HEAD"));
191191
}
192192
}
193193

@@ -197,7 +197,7 @@ public void CreatingATagForAnUnknowReferenceThrows()
197197
{
198198
using (var repo = new Repository(BareTestRepoPath))
199199
{
200-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("mytagnorev", "aaaaaaaaaaa"));
200+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mytagnorev", "aaaaaaaaaaa"));
201201
}
202202
}
203203

@@ -206,7 +206,7 @@ public void CreatingATagForANonCanonicalReferenceThrows()
206206
{
207207
using (var repo = new Repository(BareTestRepoPath))
208208
{
209-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("noncanonicaltarget", "br2"));
209+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("noncanonicaltarget", "br2"));
210210
}
211211
}
212212

@@ -216,7 +216,7 @@ public void CreatingATagForAnUnknowObjectIdThrows()
216216
{
217217
using (var repo = new Repository(BareTestRepoPath))
218218
{
219-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("mytagnorev", Constants.UnknownSha));
219+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mytagnorev", Constants.UnknownSha));
220220
}
221221
}
222222

@@ -246,7 +246,7 @@ public void CreatingADuplicateTagThrows()
246246
{
247247
repo.ApplyTag("mytag");
248248

249-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("mytag"));
249+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("mytag"));
250250
}
251251
}
252252

@@ -257,10 +257,10 @@ public void CreatingATagWithANonValidNameShouldFail()
257257
using (var repo = new Repository(BareTestRepoPath))
258258
{
259259
Assert.Throws<ArgumentException>(() => repo.ApplyTag(""));
260-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag(".othertag"));
261-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("other tag"));
262-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("othertag^"));
263-
Assert.Throws<LibGit2Exception>(() => repo.ApplyTag("other~tag"));
260+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag(".othertag"));
261+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("other tag"));
262+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("othertag^"));
263+
Assert.Throws<LibGit2SharpException>(() => repo.ApplyTag("other~tag"));
264264
}
265265
}
266266

@@ -363,7 +363,7 @@ public void BlindlyCreatingALightweightTagOverAnExistingOneThrows()
363363
{
364364
using (var repo = new Repository(BareTestRepoPath))
365365
{
366-
Assert.Throws<LibGit2Exception>(() => repo.Tags.Create("e90810b", "refs/heads/br2"));
366+
Assert.Throws<LibGit2SharpException>(() => repo.Tags.Create("e90810b", "refs/heads/br2"));
367367
}
368368
}
369369

@@ -372,7 +372,7 @@ public void BlindlyCreatingAnAnnotatedTagOverAnExistingOneThrows()
372372
{
373373
using (var repo = new Repository(BareTestRepoPath))
374374
{
375-
Assert.Throws<LibGit2Exception>(() => repo.Tags.Create("e90810b", "refs/heads/br2", signatureNtk, "a nice message"));
375+
Assert.Throws<LibGit2SharpException>(() => repo.Tags.Create("e90810b", "refs/heads/br2", signatureNtk, "a nice message"));
376376
}
377377
}
378378

@@ -381,7 +381,7 @@ public void CreateTagWithADuplicateNameThrows()
381381
{
382382
using (var repo = new Repository(BareTestRepoPath))
383383
{
384-
Assert.Throws<LibGit2Exception>(() => repo.Tags.Create("test", tagTestSha, signatureTim, "message"));
384+
Assert.Throws<LibGit2SharpException>(() => repo.Tags.Create("test", tagTestSha, signatureTim, "message"));
385385
}
386386
}
387387

@@ -408,7 +408,7 @@ public void CreateTagWithNotExistingTargetThrows()
408408
{
409409
using (var repo = new Repository(BareTestRepoPath))
410410
{
411-
Assert.Throws<LibGit2Exception>(() => repo.Tags.Create("test_tag", Constants.UnknownSha, signatureTim, "message"));
411+
Assert.Throws<LibGit2SharpException>(() => repo.Tags.Create("test_tag", Constants.UnknownSha, signatureTim, "message"));
412412
}
413413
}
414414

@@ -507,7 +507,7 @@ public void DeletingAnUnknownTagShouldFail()
507507
{
508508
using (var repo = new Repository(BareTestRepoPath))
509509
{
510-
Assert.Throws<LibGit2Exception>(() => repo.Tags.Delete("unknown-tag"));
510+
Assert.Throws<LibGit2SharpException>(() => repo.Tags.Delete("unknown-tag"));
511511
}
512512
}
513513

LibGit2Sharp/CommitCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public Commit Create(string message, Signature author, Signature committer, bool
207207
{
208208
if (amendPreviousCommit && repo.Info.IsEmpty)
209209
{
210-
throw new LibGit2Exception("Can not amend anything. The Head doesn't point at any commit.");
210+
throw new LibGit2SharpException("Can not amend anything. The Head doesn't point at any commit.");
211211
}
212212

213213
GitOid treeOid;
@@ -404,7 +404,7 @@ private IEnumerable<ObjectId> RetrieveCommitOids(object identifier)
404404
yield break;
405405
}
406406

407-
throw new LibGit2Exception(string.Format(CultureInfo.InvariantCulture, "Unexpected kind of identifier '{0}'.", identifier));
407+
throw new LibGit2SharpException(string.Format(CultureInfo.InvariantCulture, "Unexpected kind of identifier '{0}'.", identifier));
408408
}
409409
}
410410
}

LibGit2Sharp/Configuration.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public T Get<T>(string key, T defaultValue)
201201
ConfigurationSafeHandle handle = (LocalHandle ?? globalHandle) ?? systemHandle;
202202
if (handle == null)
203203
{
204-
throw new LibGit2Exception("Could not find a local, global or system level configuration.");
204+
throw new LibGit2SharpException("Could not find a local, global or system level configuration.");
205205
}
206206

207207
return (T)configurationTypedRetriever[typeof(T)](key, defaultValue, handle);
@@ -339,17 +339,17 @@ private ConfigurationSafeHandle RetrieveConfigurationHandle(ConfigurationLevel l
339339
{
340340
if (level == ConfigurationLevel.Local && !HasLocalConfig)
341341
{
342-
throw new LibGit2Exception("No local configuration file has been found. You must use ConfigurationLevel.Global when accessing configuration outside of repository.");
342+
throw new LibGit2SharpException("No local configuration file has been found. You must use ConfigurationLevel.Global when accessing configuration outside of repository.");
343343
}
344344

345345
if (level == ConfigurationLevel.Global && !HasGlobalConfig)
346346
{
347-
throw new LibGit2Exception("No global configuration file has been found.");
347+
throw new LibGit2SharpException("No global configuration file has been found.");
348348
}
349349

350350
if (level == ConfigurationLevel.System && !HasSystemConfig)
351351
{
352-
throw new LibGit2Exception("No system configuration file has been found.");
352+
throw new LibGit2SharpException("No system configuration file has been found.");
353353
}
354354

355355
ConfigurationSafeHandle h;

0 commit comments

Comments
 (0)