Skip to content

Commit

Permalink
Run dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
bording committed Nov 23, 2024
1 parent d935c49 commit 0eed453
Show file tree
Hide file tree
Showing 57 changed files with 266 additions and 261 deletions.
10 changes: 5 additions & 5 deletions LibGit2Sharp.Tests/BlameFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public void CanBlameFromVariousTypes()
string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
{
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = "HEAD" }));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = repo.Head }));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = repo.Head.Tip }));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions {StartingAt = repo.Branches["master"]}));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions { StartingAt = "HEAD" }));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions { StartingAt = repo.Head }));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions { StartingAt = repo.Head.Tip }));
AssertCorrectHeadBlame(repo.Blame("README", new BlameOptions { StartingAt = repo.Branches["master"] }));
}
}

Expand All @@ -78,7 +78,7 @@ public void CanStopBlame()
// $ git blame .\new.txt
// 9fd738e8 (Scott Chacon 2010-05-24 10:19:19 -0700 1) my new file
// (be3563a comes after 9fd738e8)
var blame = repo.Blame("new.txt", new BlameOptions {StoppingAt = "be3563a"});
var blame = repo.Blame("new.txt", new BlameOptions { StoppingAt = "be3563a" });
Assert.StartsWith("be3563a", blame[0].FinalCommit.Sha);
}
}
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/CheckoutFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public void CanForcefullyCheckoutWithConflictingStagedChanges()
Assert.Throws<CheckoutConflictException>(() => Commands.Checkout(repo, master.CanonicalName));

// Checkout with force option should succeed.
Commands.Checkout(repo, master.CanonicalName, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force});
Commands.Checkout(repo, master.CanonicalName, new CheckoutOptions() { CheckoutModifiers = CheckoutModifiers.Force });

// Assert that master branch is checked out.
Assert.True(repo.Branches["master"].IsCurrentRepositoryHead);
Expand Down Expand Up @@ -411,7 +411,7 @@ public void CheckingOutThroughBranchCallsCheckoutProgress()

Branch branch = repo.Branches[otherBranchName];
Commands.Checkout(repo, branch,
new CheckoutOptions { OnCheckoutProgress = (path, completed, total) => wasCalled = true});
new CheckoutOptions { OnCheckoutProgress = (path, completed, total) => wasCalled = true });

Assert.True(wasCalled);
}
Expand All @@ -427,7 +427,7 @@ public void CheckingOutThroughRepositoryCallsCheckoutProgress()
PopulateBasicRepository(repo);
bool wasCalled = false;

Commands.Checkout(repo, otherBranchName, new CheckoutOptions() { OnCheckoutProgress = (path, completed, total) => wasCalled = true});
Commands.Checkout(repo, otherBranchName, new CheckoutOptions() { OnCheckoutProgress = (path, completed, total) => wasCalled = true });

Assert.True(wasCalled);
}
Expand Down Expand Up @@ -779,7 +779,7 @@ public void CheckoutFromDetachedHead(string commitPointer)
public void CheckoutBranchFromDetachedHead()
{
string path = SandboxStandardTestRepo();
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
{
// Set the working directory to the current head
ResetAndCleanWorkingDirectory(repo);
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/ConflictFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static List<object[]> RenameConflictData

[Theory]
[InlineData(true, "ancestor-and-ours.txt", true, false, FileStatus.DeletedFromIndex, 2)]
[InlineData(false, "ancestor-and-ours.txt", true, true, FileStatus.DeletedFromIndex |FileStatus.NewInWorkdir, 2)]
[InlineData(false, "ancestor-and-ours.txt", true, true, FileStatus.DeletedFromIndex | FileStatus.NewInWorkdir, 2)]
[InlineData(true, "ancestor-and-theirs.txt", true, false, FileStatus.Nonexistent, 2)]
[InlineData(false, "ancestor-and-theirs.txt", true, true, FileStatus.NewInWorkdir, 2)]
[InlineData(true, "ancestor-only.txt", false, false, FileStatus.Nonexistent, 1)]
Expand Down Expand Up @@ -101,7 +101,7 @@ public void CanGetOriginalNamesOfRenameConflicts()
Assert.Equal(expected.Count, actual.Count());

int i = 0;
foreach(var name in actual)
foreach (var name in actual)
{
Assert.Equal(expected[i][0], name.Ancestor);
Assert.Equal(expected[i][1], name.Ours);
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/DescribeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void CanDescribeACommit()

// No lightweight tags can either be used to describe "master"
Assert.Throws<NotFoundException>(() => repo.Describe(masterTip,
new DescribeOptions{ Strategy = DescribeStrategy.Tags }));
new DescribeOptions { Strategy = DescribeStrategy.Tags }));

repo.ApplyTag("myTag", "5b5b025afb0b4c913b4c338a42934a3863bf3644");
Assert.Equal("myTag-5-g4c062a6", repo.Describe(masterTip,
Expand All @@ -47,7 +47,7 @@ public void CanDescribeACommit()
var anotherTip = repo.Branches["ForLackOfABetterName"].Tip;
Assert.Equal("test", repo.Describe(anotherTip));
Assert.Equal("test-0-g7b43849", repo.Describe(anotherTip,
new DescribeOptions{ AlwaysRenderLongFormat = true }));
new DescribeOptions { AlwaysRenderLongFormat = true }));
}
}

Expand Down
6 changes: 3 additions & 3 deletions LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ public void DiffThrowsANotFoundExceptionIfATreeIsMissing()
string repoPath = SandboxBareTestRepo();

// Manually delete the tree object to simulate a partial clone
File.Delete(Path.Combine(repoPath, "objects", "58", "1f9824ecaf824221bd36edf5430f2739a7c4f5"));
File.Delete(Path.Combine(repoPath, "objects", "58", "1f9824ecaf824221bd36edf5430f2739a7c4f5"));

using (var repo = new Repository(repoPath))
{
Expand All @@ -1282,12 +1282,12 @@ public void DiffThrowsANotFoundExceptionIfATreeIsMissing()

Assert.Throws<NotFoundException>(() =>
{
using (repo.Diff.Compare<TreeChanges>(commit.Tree, otherCommit.Tree)) {}
using (repo.Diff.Compare<TreeChanges>(commit.Tree, otherCommit.Tree)) { }
});

Assert.Throws<NotFoundException>(() =>
{
using (repo.Diff.Compare<TreeChanges>(otherCommit.Tree, commit.Tree)) {}
using (repo.Diff.Compare<TreeChanges>(otherCommit.Tree, commit.Tree)) { }
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/DiffWorkdirToIndexFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
using (var repo = new Repository(path))
{
SetFilemode(repo, true);
using(var changes = repo.Diff.Compare<TreeChanges>(new[] { file }))
using (var changes = repo.Diff.Compare<TreeChanges>(new[] { file }))
{
Assert.Single(changes);

Expand All @@ -150,7 +150,7 @@ public void ComparingReliesOnProvidedConfigEntriesIfAny()
using (var repo = new Repository(path))
{
SetFilemode(repo, false);
using(var changes = repo.Diff.Compare<TreeChanges>(new[] { file }))
using (var changes = repo.Diff.Compare<TreeChanges>(new[] { file }))
{
Assert.Empty(changes);
}
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/FileHistoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void CanTellComplexCommitHistory()
var commit4 = MakeAndCommitChange(repo, repoPath, newPath1, "I have done it again!");

// Perform tests.
var commitFilter = new CommitFilter () { SortBy = CommitSortStrategies.Topological };
var commitFilter = new CommitFilter() { SortBy = CommitSortStrategies.Topological };
var fileHistoryEntries = repo.Commits.QueryBy(newPath1, commitFilter).ToList();
var changedBlobs = fileHistoryEntries.Blobs().Distinct().ToList();

Expand Down
10 changes: 5 additions & 5 deletions LibGit2Sharp.Tests/MergeFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public void CanFastForwardCommit(bool fromDetachedHead, FastForwardStrategy fast
string path = SandboxMergeTestRepo();
using (var repo = new Repository(path))
{
if(fromDetachedHead)
if (fromDetachedHead)
{
Commands.Checkout(repo, repo.Head.Tip.Id.Sha);
}
Expand Down Expand Up @@ -512,7 +512,7 @@ public void CanMergeAndNotCommit()
{
Commit commitToMerge = repo.Branches["normal_merge"].Tip;

MergeResult result = repo.Merge(commitToMerge, Constants.Signature, new MergeOptions() { CommitOnSuccess = false});
MergeResult result = repo.Merge(commitToMerge, Constants.Signature, new MergeOptions() { CommitOnSuccess = false });

Assert.Equal(MergeStatus.NonFastForward, result.Status);
Assert.Null(result.Commit);
Expand Down Expand Up @@ -649,7 +649,7 @@ public void CanSpecifyConflictFileStrategy(CheckoutFileConflictStrategy conflict

// Get the blob containing the expected content.
Blob expectedBlob = null;
switch(conflictStrategy)
switch (conflictStrategy)
{
case CheckoutFileConflictStrategy.Theirs:
expectedBlob = repo.Lookup<Blob>(conflict.Theirs.Id);
Expand Down Expand Up @@ -731,7 +731,7 @@ public void CanMergeBranch(string branchName, FastForwardStrategy strategy, Merg
string path = SandboxMergeTestRepo();
using (var repo = new Repository(path))
{
Branch branch = repo. Branches[branchName];
Branch branch = repo.Branches[branchName];
MergeResult result = repo.Merge(branch, Constants.Signature, new MergeOptions() { FastForwardStrategy = strategy });

Assert.Equal(expectedMergeStatus, result.Status);
Expand All @@ -748,7 +748,7 @@ public void CanMergeIntoOrphanedBranch()
repo.Refs.Add("HEAD", "refs/heads/orphan", true);

// Remove entries from the working directory
foreach(var entry in repo.RetrieveStatus())
foreach (var entry in repo.RetrieveStatus())
{
Commands.Unstage(repo, entry.FilePath);
Commands.Remove(repo, entry.FilePath, true);
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/NoteFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void RetrievingNotesFromAGitObjectWhichHasNoNoteYieldsNoResult()
[Fact]
public void CanRetrieveNotesFromAGitObject()
{
var expectedMessages = new [] { "Just Note, don't you understand?\n", "Nope\n", "Not Nope, Note!\n" };
var expectedMessages = new[] { "Just Note, don't you understand?\n", "Nope\n", "Not Nope, Note!\n" };

string path = SandboxBareTestRepo();
using (var repo = new Repository(path))
Expand Down
8 changes: 4 additions & 4 deletions LibGit2Sharp.Tests/OdbBackendFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static Commit AddCommitToRepo(IRepository repo)
var commit = repo.Commit("Initial commit", author, author);

relativeFilepath = "big.txt";
var zeros = new string('0', 32*1024 + 3);
var zeros = new string('0', 32 * 1024 + 3);
Touch(repo.Info.WorkingDirectory, relativeFilepath, zeros);
Commands.Stage(repo, relativeFilepath);

Expand Down Expand Up @@ -145,7 +145,7 @@ public void CanEnumerateTheContentOfTheObjectDatabase()

AddCommitToRepo(repo);

var expected = new[]{ "1fe3126", "2b297e6", "6518215", "9daeafb" };
var expected = new[] { "1fe3126", "2b297e6", "6518215", "9daeafb" };

IEnumerable<GitObject> objs = repo.ObjectDatabase;

Expand Down Expand Up @@ -296,7 +296,7 @@ public override int Read(ObjectId oid, out UnmanagedMemoryStream data, out Objec

if (!m_objectIdToContent.TryGetValue(oid, out gitObject))
{
return (int) ReturnCode.GIT_ENOTFOUND;
return (int)ReturnCode.GIT_ENOTFOUND;
}

data = Allocate(gitObject.Length);
Expand Down Expand Up @@ -411,7 +411,7 @@ public override int ExistsPrefix(string shortSha, out ObjectId found)
if (numFound > 1)
{
found = null;
return (int) ReturnCode.GIT_EAMBIGUOUS;
return (int)ReturnCode.GIT_EAMBIGUOUS;
}
}

Expand Down
56 changes: 28 additions & 28 deletions LibGit2Sharp.Tests/PatchEntryChangesFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@

namespace LibGit2Sharp.Tests
{
public class PatchEntryChangesFixture : BaseFixture
{
[Fact]
public void PatchEntryBasics()
public class PatchEntryChangesFixture : BaseFixture
{
// Init test repo
var path = SandboxStandardTestRepoGitDir();
string file = "numbers.txt";
[Fact]
public void PatchEntryBasics()
{
// Init test repo
var path = SandboxStandardTestRepoGitDir();
string file = "numbers.txt";

// The repo
using (var repo = new Repository(path))
{
Tree rootCommitTree = repo.Lookup<Commit>("f8d44d7").Tree;
Tree commitTreeWithUpdatedFile = repo.Lookup<Commit>("ec9e401").Tree;
// The repo
using (var repo = new Repository(path))
{
Tree rootCommitTree = repo.Lookup<Commit>("f8d44d7").Tree;
Tree commitTreeWithUpdatedFile = repo.Lookup<Commit>("ec9e401").Tree;

// Create patch by diffing
using (var patch = repo.Diff.Compare<Patch>(rootCommitTree, commitTreeWithUpdatedFile))
{
PatchEntryChanges entryChanges = patch[file];
Assert.Equal(2, entryChanges.LinesAdded);
Assert.Equal(1, entryChanges.LinesDeleted);
Assert.Equal(187, entryChanges.Patch.Length);
// Smoke test
Assert.Equal(Mode.NonExecutableFile, entryChanges.Mode);
Assert.Equal(new ObjectId("4625a3628cb78970c57e23a2fe2574514ba403c7"), entryChanges.Oid);
Assert.Equal(ChangeKind.Modified, entryChanges.Status);
Assert.Equal(file, entryChanges.OldPath);
Assert.Equal(Mode.NonExecutableFile, entryChanges.OldMode);
Assert.Equal(new ObjectId("7909961ae96accd75b6813d32e0fc1d6d52ec941"), entryChanges.OldOid);
// Create patch by diffing
using (var patch = repo.Diff.Compare<Patch>(rootCommitTree, commitTreeWithUpdatedFile))
{
PatchEntryChanges entryChanges = patch[file];
Assert.Equal(2, entryChanges.LinesAdded);
Assert.Equal(1, entryChanges.LinesDeleted);
Assert.Equal(187, entryChanges.Patch.Length);
// Smoke test
Assert.Equal(Mode.NonExecutableFile, entryChanges.Mode);
Assert.Equal(new ObjectId("4625a3628cb78970c57e23a2fe2574514ba403c7"), entryChanges.Oid);
Assert.Equal(ChangeKind.Modified, entryChanges.Status);
Assert.Equal(file, entryChanges.OldPath);
Assert.Equal(Mode.NonExecutableFile, entryChanges.OldMode);
Assert.Equal(new ObjectId("7909961ae96accd75b6813d32e0fc1d6d52ec941"), entryChanges.OldOid);
}
}
}
}
}
}
}
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/RebaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void CanRebase(string initialBranchName,

RebaseOptions options = new RebaseOptions()
{
RebaseStepStarting = x =>
RebaseStepStarting = x =>
{
beforeRebaseStepCountCorrect &= beforeStepCallCount == x.StepIndex;
totalStepCountCorrect &= (x.TotalStepCount == stepCount);
Expand Down Expand Up @@ -276,7 +276,7 @@ public void VerifyRebaseDetailed(string attributes, string lineEnding, string[]
List<Commit> rebasedCommits = repo.Commits.QueryBy(commitFilter).ToList();

Assert.Equal(3, rebasedCommits.Count);
for(int i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
Assert.Equal(expectedTreeIds[i], rebasedCommits[i].Tree.Id);
Assert.Equal(Constants.Signature.Name, rebasedCommits[i].Author.Name);
Expand Down
2 changes: 1 addition & 1 deletion LibGit2Sharp.Tests/RefSpecFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void CanReplaceRefSpecs(string[] newFetchRefSpecs, string[] newPushRefSpe

repo.Network.Remotes.Update("origin",
r => r.FetchRefSpecs = newFetchRefSpecs, r => r.PushRefSpecs = newPushRefSpecs);
Assert.Equal(oldRefSpecs, remote.RefSpecs.ToList());
Assert.Equal(oldRefSpecs, remote.RefSpecs.ToList());
}

using (var newRemote = repo.Network.Remotes["origin"])
Expand Down
4 changes: 2 additions & 2 deletions LibGit2Sharp.Tests/ReferenceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public void CanUpdateTargetOfADirectReferenceWithAnAbbreviatedSha()
Reference master = repo.Refs[masterRef];
Assert.NotEqual(sha, master.ResolveToDirectReference().Target.Sha);

Reference updated = repo.Refs.UpdateTarget(masterRef, sha.Substring(0,4));
Reference updated = repo.Refs.UpdateTarget(masterRef, sha.Substring(0, 4));

master = repo.Refs[masterRef];
Assert.Equal(updated, master);
Expand Down Expand Up @@ -556,7 +556,7 @@ public void CanUpdateTargetOfADirectReferenceWithARevparseSpec()

const string name = "refs/heads/master";

var master = (DirectReference) repo.Refs[name];
var master = (DirectReference)repo.Refs[name];
var @from = master.Target.Id;

const string logMessage = "update target message";
Expand Down
6 changes: 3 additions & 3 deletions LibGit2Sharp.Tests/RemoveFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class RemoveFixture : BaseFixture
* 'git rm <file>' fails ("error: '<file>' has local modifications").
*/
[InlineData(false, "modified_unstaged_file.txt", false, FileStatus.ModifiedInWorkdir, true, true, FileStatus.NewInWorkdir | FileStatus.DeletedFromIndex)]
[InlineData(true, "modified_unstaged_file.txt", true, FileStatus.ModifiedInWorkdir, true, true, FileStatus.Unaltered)]
[InlineData(true, "modified_unstaged_file.txt", true, FileStatus.ModifiedInWorkdir, true, true, FileStatus.Unaltered)]
/***
* Test case: modified file in wd, the modifications have already been promoted to the index.
* 'git rm --cached <file>' works (removes the file from the index)
Expand Down Expand Up @@ -150,7 +150,7 @@ public void RemovingAnUnknownFileWithLaxExplicitPathsValidationDoesntThrow(strin

Commands.Remove(repo, relativePath, i % 2 == 0);
Commands.Remove(repo, relativePath, i % 2 == 0,
new ExplicitPathsOptions {ShouldFailOnUnmatchedPath = false});
new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false });
}
}
}
Expand All @@ -169,7 +169,7 @@ public void RemovingAnUnknownFileThrowsIfExplicitPath(string relativePath, FileS
Assert.Equal(status, repo.RetrieveStatus(relativePath));

Assert.Throws<UnmatchedPathException>(
() => Commands.Remove(repo, relativePath, i%2 == 0, new ExplicitPathsOptions()));
() => Commands.Remove(repo, relativePath, i % 2 == 0, new ExplicitPathsOptions()));
}
}
}
Expand Down
Loading

0 comments on commit 0eed453

Please sign in to comment.