8000 Favor Constants.Signature over BaseFixture.DummySignature · freevoid/libgit2sharp@fd398ef · GitHub
[go: up one dir, main page]

Skip to content

Commit fd398ef

Browse files
committed
Favor Constants.Signature over BaseFixture.DummySignature
1 parent be0b83c commit fd398ef

12 files changed

+38
-40
lines changed

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ public void TrackedBranchExistsFromDefaultConfigInEmptyClone()
826826

827827
Touch(repo.Info.WorkingDirectory, "a.txt", "a");
828828
repo.Index.Stage("a.txt");
829-
repo.Commit("A file", DummySignature, DummySignature);
829+
repo.Commit("A file", Constants.Signature, Constants.Signature);
830830

831831
Assert.NotNull(repo.Head.Tip);
832832
Assert.NotNull(repo.Head.TrackedBranch);

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public void CommitParentsAreMergeHeads()
558558

559559
Assert.Equal(CurrentOperation.Merge, repo.Info.CurrentOperation);
560560

561-
Commit newMergedCommit = repo.Commit("Merge commit", DummySignature, DummySignature);
561+
Commit newMergedCommit = repo.Commit("Merge commit", Constants.Signature, Constants.Signature);
562562

563563
Assert.Equal(CurrentOperation.None, repo.Info.CurrentOperation);
564564

@@ -600,7 +600,7 @@ public void CommitCleansUpMergeMetadata()
600600
Assert.True(File.Exists(mergeModePath));
601601
Assert.True(File.Exists(origHeadPath));
602602

603-
var author = DummySignature;
603+
var author = Constants.Signature;
604604
repo.Commit("Initial egotistic commit", author, author);
605605

606606
Assert.False(File.Exists(mergeHeadPath));
@@ -629,7 +629,7 @@ public void CanCommitALittleBit()
629629

630630
Assert.Null(repo.Head[relativeFilepath]);
631631

632-
var author = DummySignature;
632+
var author = Constants.Signature;
633633

634634
const string shortMessage = "Initial egotistic commit";
635635
const string commitMessage = shortMessage + "\n\nOnly the coolest commits from us";
@@ -746,7 +746,7 @@ public void CanAmendARootCommit()
746746

747747
CreateAndStageANewFile(repo);
748748

749-
Commit amendedCommit = repo.Commit("I'm rewriting the history!", DummySignature, DummySignature, true);
749+
Commit amendedCommit = repo.Commit("I'm rewriting the history!", Constants.Signature, Constants.Signature, true);
750750

751751
Assert.Equal(1, repo.Head.Commits.Count());
752752

@@ -769,7 +769,7 @@ public void CanAmendACommitWithMoreThanOneParent()
769769
CreateAndStageANewFile(repo);
770770
const string commitMessage = "I'm rewriting the history!";
771771

772-
Commit amendedCommit = repo.Commit(commitMessage, DummySignature, DummySignature, true);
772+
Commit amendedCommit = repo.Commit(commitMessage, Constants.Signature, Constants.Signature, true);
773773

774774
AssertCommitHasBeenAmended(repo, amendedCommit, mergedCommit);
775775

@@ -804,7 +804,7 @@ public void CanNotAmendAnEmptyRepository()
804804

805805
using (var repo = new Repository(repoPath))
806806
{
807-
Assert.Throws<OrphanedHeadException>(() => repo.Commit("I can not amend anything !:(", DummySignature, DummySignature, true));
807+
Assert.Throws<OrphanedHeadException>(() => repo.Commit("I can not amend anything !:(", Constants.Signature, Constants.Signature, true));
808808
}
809809
}
810810

@@ -875,7 +875,7 @@ public void CanCommitOnOrphanedBranch()
875875
Touch(repo.Info.WorkingDirectory, relativeFilepath, "test\n");
876876
repo.Index.Stage(relativeFilepath);
877877

878-
repo.Commit("Initial commit", DummySignature, DummySignature);
878+
repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
879879
Assert.Equal(1, repo.Head.Commits.Count());
880880
}
881881
}

LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ private static void SetUpSimpleDiffContext(Repository repo)
1313
var fullpath = Touch(repo.Info.WorkingDirectory, "file.txt", "hello\n");
1414

1515
repo.Index.Stage(fullpath);
16-
repo.Commit("Initial commit", DummySignature, DummySignature);
16+
repo.Commit("Initial commit", Constants.Signature, Constants.Signature);
1717

1818
File.AppendAllText(fullpath, "world\n");
1919

@@ -354,7 +354,7 @@ public void CanCopeWithEndOfFileNewlineChanges()
354354
var fullpath = Touch(repo.Info.WorkingDirectory, "file.txt", "a");
355355

356356
repo.Index.Stage("file.txt");
357-
repo.Commit("Add file without line ending", DummySignature, DummySignature);
357+
repo.Commit("Add file without line ending", Constants.Signature, Constants.Signature);
358358

359359
File.AppendAllText(fullpath, "\n");
360360
repo.Index.Stage("file.txt");

LibGit2Sharp.Tests/FilterBranchFixture.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ public void CanRewriteAuthorOfCommits()
6464
public void CanRewriteAuthorOfCommitsOnlyBeingPointedAtByTags()
6565
{
6666
var commit = repo.ObjectDatabase.CreateCommit(
67-
"I'm a lonesome commit", DummySignature, DummySignature,
67+
"I'm a lonesome commit", Constants.Signature, Constants.Signature,
6868
repo.Head.Tip.Tree, Enumerable.Empty<Commit>());
6969

7070
repo.Tags.Add("so-lonely", commit);
7171

72-
repo.Tags.Add("so-lonely-but-annotated", commit, DummySignature,
72+
repo.Tags.Add("so-lonely-but-annotated", commit, Constants.Signature,
7373
"Yeah, baby! I'm going to be rewritten as well");
7474

7575
repo.Refs.RewriteHistory(
@@ -106,19 +106,19 @@ public void OnlyRewriteSelectedCommits()
106106
var parent = commit.Parents.Single();
107107

108108
Assert.True(parent.Sha.StartsWith("5001298"));
109-
Assert.NotEqual(DummySignature, commit.Author);
110-
Assert.NotEqual(DummySignature, parent.Author);
109+
Assert.NotEqual(Constants.Signature, commit.Author);
110+
Assert.NotEqual(Constants.Signature, parent.Author);
111111

112112
repo.Refs.RewriteHistory(
113113
new[] { parent },
114-
commitHeaderRewriter: c => CommitRewriteInfo.From(c, author: DummySignature));
114+
commitHeaderRewriter: c => CommitRewriteInfo.From(c, author: Constants.Signature));
115115

116116
commit = repo.Branches["packed"].Tip;
117117
parent = commit.Parents.Single();
118118

119119
Assert.False(parent.Sha.StartsWith("5001298"));
120-
Assert.NotEqual(DummySignature, commit.Author);
121-
Assert.Equal(DummySignature, parent.Author);
120+
Assert.NotEqual(Constants.Signature, commit.Author);
121+
Assert.Equal(Constants.Signature, parent.Author);
122122
}
123123

124124
[Fact]
@@ -302,7 +302,7 @@ public void CanRewriteSymbolicRefsPointingToTags()
302302
repo.Refs.Add("refs/attic/dusty_tracker", "refs/tags/another_tracker");
303303

304304
repo.Refs.RewriteHistory(new[] { repo.Lookup<Commit>("e90810b8df") },
305-
c => CommitRewriteInfo.From(c, author: DummySignature),
305+
c => CommitRewriteInfo.From(c, author: Constants.Signature),
306306
tagNameRewriter: (oldName, isAnnotated, o) => oldName + "_new");
307307

308308
// Ensure the initial tags don't exist anymore...
@@ -330,8 +330,8 @@ public void HandlesNameRewritingOfChainedTags()
330330
// Add a lightweight tag (A) that points to tag annotation (B) that points to another tag annotation (C),
331331
// which points to a commit
332332
var theCommit = repo.Lookup<Commit>("6dcf9bf");
333-
var annotationC = repo.ObjectDatabase.CreateTagAnnotation("annotationC", theCommit, DummySignature, "");
334-
var annotationB = repo.ObjectDatabase.CreateTagAnnotation("annotationB", annotationC, DummySignature, "");
333+
var annotationC = repo.ObjectDatabase.CreateTagAnnotation("annotationC", theCommit, Constants.Signature, "");
334+
var annotationB = repo.ObjectDatabase.CreateTagAnnotation("annotationB", annotationC, Constants.Signature, "");
335335
var tagA = repo.Tags.Add("lightweightA", annotationB);
336336

337337
// Rewrite the commit, renaming the tag

LibGit2Sharp.Tests/MergeFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void CommitAgainARepoWithUnmergedEntriesThrows()
5454
{
5555
Assert.Equal(false, repo.Index.IsFullyMerged);
5656

57-
var author = DummySignature;
57+
var author = Constants.Signature;
5858
Assert.Throws<UnmergedIndexEntriesException>(
5959
() => repo.Commit("Try commit unmerged entries", author, author));
6060
}

LibGit2Sharp.Tests/ObjectDatabaseFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public void CanCreateATreeContainingAGitLinkFromAnUntrackedSubmoduleInTheWorking
311311
Assert.IsType<GitLink>(te.Target);
312312
Assert.Equal(objectId, te.Target.Id);
313313

314-
var commitWithSubmodule = repo.ObjectDatabase.CreateCommit("Submodule!", DummySignature, DummySignature, tree,
314+
var commitWithSubmodule = repo.ObjectDatabase.CreateCommit("Submodule!", Constants.Signature, Constants.Signature, tree,
315315
new[] { repo.Head.Tip });
316316
repo.Reset(ResetOptions.Soft, commitWithSubmodule);
317317

@@ -348,7 +348,7 @@ public void CanCreateACommit()
348348

349349
Tree tree = repo.ObjectDatabase.CreateTree(td);
350350

351-
Commit commit = repo.ObjectDatabase.CreateCommit("Ü message", DummySignature, DummySignature, tree, new[] { repo.Head.Tip });
351+
Commit commit = repo.ObjectDatabase.CreateCommit("Ü message", Constants.Signature, Constants.Signature, tree, new[] { repo.Head.Tip });
352352

353353
Branch newHead = repo.Head;
354354

@@ -387,7 +387,7 @@ public void CanCreateATagAnnotationPointingToAGitObject()
387387
TagAnnotation tag = repo.ObjectDatabase.CreateTagAnnotation(
388388
"nice_blob",
389389
blob,
390-
DummySignature,
390+
Constants.Signature,
391391
"I can point at blobs, too!");
392392

393393
Assert.NotNull(tag);

LibGit2Sharp.Tests/PushFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private void AssertPush(Action<Repository> push)
3636
const string relativeFilepath = "new_file.txt";
3737
Touch(clonedRepo.Info.WorkingDirectory, relativeFilepath, "__content__");
3838
clonedRepo.Index.Stage(relativeFilepath);
39-
clonedRepo.Commit("__commit_message__", DummySignature, DummySignature);
39+
clonedRepo.Commit("__commit_message__", Constants.Signature, Constants.Signature);
4040

4141
// Assert local state has changed
4242
Assert.NotEqual(originalRepo.Refs["HEAD"].ResolveToDirectReference().TargetIdentifier,

LibGit2Sharp.Tests/ReflogFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void CommitShouldCreateReflogEntryOnHeadandOnTargetedDirectReference()
5454
Touch(repo.Info.WorkingDirectory, relativeFilepath, "content\n");
5555
repo.Index.Stage(relativeFilepath);
5656

57-
var author = DummySignature;
57+
var author = Constants.Signature;
5858
const string commitMessage = "Hope reflog behaves as it should";
5959
Commit commit = repo.Commit(commitMessage, author, author);
6060

@@ -88,7 +88,7 @@ public void CommitOnUnbornReferenceShouldCreateReflogEntryWithInitialTag()
8888
Touch(repo.Info.WorkingDirectory, relativeFilepath, "content\n");
8989
repo.Index.Stage(relativeFilepath);
9090

91-
var author = DummySignature;
91+
var author = Constants.Signature;
9292
const string commitMessage = "First commit should be logged as initial";
9393
repo.Commit(commitMessage, author, author);
9494

@@ -115,7 +115,7 @@ public void CommitOnDetachedHeadShouldInsertReflogEntry()
115115
Touch(repo.Info.WorkingDirectory, relativeFilepath, "content\n");
116116
repo.Index.Stage(relativeFilepath);
117117

118-
var author = DummySignature;
118+
var author = Constants.Signature;
119119
const string commitMessage = "Commit on detached head";
120120
var commit = repo.Commit(commitMessage, author, author);
121121

LibGit2Sharp.Tests/RepositoryOptionsFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private string MeanwhileInAnotherDimensionAnEvilMastermindIsAtWork(string workin
133133
Touch(sneakyRepo.Info.WorkingDirectory, filename, "I'm being sneaked in!\n");
134134

135135
sneakyRepo.Index.Stage(filename);
136-
return sneakyRepo.Commit("Tadaaaa!", DummySignature, DummySignature).Sha;
136+
return sneakyRepo.Commit("Tadaaaa!", Constants.Signature, Constants.Signature).Sha;
137137
}
138138
}
139139

LibGit2Sharp.Tests/StashFixture.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void CannotAddStashAgainstBareRepository()
1515
string path = CloneBareTestRepo();
1616
using (var repo = new Repository(path))
1717
{
18-
var stasher = DummySignature;
18+
var stasher = Constants.Signature;
1919

2020
Assert.Throws<BareRepositoryException>(() => repo.Stashes.Add(stasher, "My very first stash", StashModifiers.Default));
2121
}
@@ -27,7 +27,7 @@ public void CanAddAndRemoveStash()
2727
string path = CloneStandardTestRepo();
2828
using (var repo = new Repository(path))
2929
{
30-
var stasher = DummySignature;
30+
var stasher = Constants.Signature;
3131

3232
Assert.True(repo.Index.RetrieveStatus().IsDirty);
3333

@@ -81,7 +81,7 @@ public void AddingAStashWithNoMessageGeneratesADefaultOne()
8181
string path = CloneStandardTestRepo();
8282
using (var repo = new Repository(path))
8383
{
84-
var stasher = DummySignature;
84+
var stasher = Constants.Signature;
8585

8686
Stash stash = repo.Stashes.Add(stasher, options: StashModifiers.Default);
8787

@@ -110,7 +110,7 @@ public void StashingAgainstCleanWorkDirShouldReturnANullStash()
110110
string path = CloneStandardTestRepo();
111111
using (var repo = new Repository(path))
112112
{
113-
var stasher = DummySignature;
113+
var stasher = Constants.Signature;
114114

115115
Stash stash = repo.Stashes.Add(stasher, "My very first stash", StashModifiers.IncludeUntracked);
116116

@@ -127,7 +127,7 @@ public void CanStashWithoutOptions()
127127
string path = CloneStandardTestRepo();
128128
using (var repo = new Repository(path))
129129
{
130-
var stasher = DummySignature;
130+
var stasher = Constants.Signature;
131131

132132
const string untracked = "new_untracked_file.txt";
133133
Touch(repo.Info.WorkingDirectory, untracked, "I'm untracked\n");
@@ -154,7 +154,7 @@ public void CanStashAndKeepIndex()
154154
string path = CloneStandardTestRepo();
155155
using (var repo = new Repository(path))
156156
{
157-
var stasher = DummySignature;
157+
var stasher = Constants.Signature;
158158

159159
const string filename = "staged_file_path.txt";
160160
Touch(repo.Info.WorkingDirectory, filename, "I'm staged\n");
@@ -184,7 +184,7 @@ public void CanStashIgnoredFiles()
184184

185185
Assert.True(repo.Ignore.IsPathIgnored(ignoredFilename));
186186

187-
var stasher = DummySignature;
187+
var stasher = Constants.Signature;
188188
repo.Stashes.Add(stasher, "This stash includes ignore files", StashModifiers.IncludeIgnored);
189189

190190
//TODO : below assertion doesn't pass. Bug?
@@ -213,7 +213,7 @@ public void CanGetStashByIndexer()
213213
string path = CloneStandardTestRepo();
214214
using (var repo = new Repository(path))
215215
{
216-
var stasher = DummySignature;
216+
var stasher = Constants.Signature;
217217
const string firstStashMessage = "My very first stash";
218218
const string secondStashMessage = "My second stash";
219219
const string thirdStashMessage = "My third stash";

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ FileStatus expectedCamelCasedFileStatus
270270
lowerCasedPath = Touch(repo.Info.WorkingDirectory, lowercasedFilename);
271271

272272
repo.Index.Stage(lowercasedFilename);
273-
repo.Commit("initial", DummySignature, DummySignature);
273+
repo.Commit("initial", Constants.Signature, Constants.Signature);
274274
}
275275

276276
using (var repo = new Repository(repoPath))

LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ static BaseFixture()
2929
public static string SubmoduleTestRepoWorkingDirPath { get; private set; }
3030
public static DirectoryInfo ResourcesDirectory { get; private set; }
3131

32-
public static readonly Signature DummySignature = new Signature("Author N. Ame", "him@there.com", TruncateSubSeconds(DateTimeOffset.Now));
33-
3432
public static bool IsFileSystemCaseSensitive { get; private set; }
3533

3634
protected static DateTimeOffset TruncateSubSeconds(DateTimeOffset dto)

0 commit comments

Comments
 (0)
0