Skip to content

Commit d9c333e

Browse files
committed
reformating files with resharper layout
1 parent 9089e4e commit d9c333e

File tree

3 files changed

+59
-63
lines changed

3 files changed

+59
-63
lines changed

LibGit2Sharp.Tests/ReferenceFixture.cs

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace LibGit2Sharp.Tests
99
[TestFixture]
1010
public class ReferenceFixture
1111
{
12-
private readonly List<string> expectedRefs = new List<string> { "refs/heads/packed-test", "refs/heads/packed", "refs/heads/br2", "refs/heads/master", "refs/heads/test", "refs/tags/test", "refs/tags/e90810b", "refs/tags/lw" };
12+
private readonly List<string> expectedRefs = new List<string> {"refs/heads/packed-test", "refs/heads/packed", "refs/heads/br2", "refs/heads/master", "refs/heads/test", "refs/tags/test", "refs/tags/e90810b", "refs/tags/lw"};
1313

1414
[Test]
1515
public void CanCreateReferenceFromSha()
@@ -40,32 +40,13 @@ public void CanCreateReferenceFromSymbol()
4040
newRef.ShouldNotBeNull();
4141
newRef.CanonicalName.ShouldEqual(name);
4242
newRef.Target.ShouldNotBeNull();
43-
((DirectReference)newRef.Target).Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
43+
((DirectReference) newRef.Target).Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
4444
repo.Refs.SingleOrDefault(p => p.CanonicalName == name).ShouldNotBeNull();
4545

4646
repo.Refs.Delete(newRef.CanonicalName);
4747
}
4848
}
4949

50-
[Test]
51-
public void DeleteWithNullNameThrows()
52-
{
53-
using (var repo = new Repository(Constants.TestRepoPath))
54-
{
55-
Assert.Throws<ArgumentNullException>(() => repo.Refs.Delete(null));
56-
}
57-
}
58-
59-
[Test]
60-
public void DeleteWithEmptyNameThrows()
61-
{
62-
using (var repo = new Repository(Constants.TestRepoPath))
63-
{
64-
Assert.Throws<ArgumentException>(() => repo.Refs.Delete(string.Empty));
65-
}
66-
}
67-
68-
6950
[Test]
7051
public void CanListAllReferences()
7152
{
@@ -90,7 +71,7 @@ public void CanResolveHeadByName()
9071
head.CanonicalName.ShouldEqual("HEAD");
9172
head.Target.ShouldNotBeNull();
9273
head.Target.CanonicalName.ShouldEqual("refs/heads/master");
93-
((DirectReference)head.Target).Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
74+
((DirectReference) head.Target).Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
9475
Assert.IsInstanceOf<Commit>(((DirectReference) head.Target).Target);
9576

9677
var head2 = (SymbolicReference) repo.Refs.Head;
@@ -103,30 +84,30 @@ public void CanResolveHeadByName()
10384
}
10485

10586
[Test]
106-
public void CanResolveReferenceToAnAnnotatedTag()
87+
public void CanResolveReferenceToALightweightTag()
10788
{
10889
using (var repo = new Repository(Constants.TestRepoPath))
10990
{
110-
var annTag = (DirectReference)repo.Refs["refs/tags/test"];
111-
annTag.ShouldNotBeNull();
112-
annTag.CanonicalName.ShouldEqual("refs/tags/test");
113-
annTag.Target.ShouldNotBeNull();
114-
annTag.Target.Sha.ShouldEqual("b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
115-
Assert.IsInstanceOf<TagAnnotation>(annTag.Target);
91+
var lwTag = (DirectReference) repo.Refs["refs/tags/lw"];
92+
lwTag.ShouldNotBeNull();
93+
lwTag.CanonicalName.ShouldEqual("refs/tags/lw");
94+
lwTag.Target.ShouldNotBeNull();
95+
lwTag.Target.Sha.ShouldEqual("e90810b8df3e80c413d903f631643c716887138d");
96+
Assert.IsInstanceOf<Commit>(lwTag.Target);
11697
}
11798
}
11899

119100
[Test]
120-
public void CanResolveReferenceToALightweightTag()
101+
public void CanResolveReferenceToAnAnnotatedTag()
121102
{
122103
using (var repo = new Repository(Constants.TestRepoPath))
123104
{
124-
var lwTag = (DirectReference)repo.Refs["refs/tags/lw"];
125-
lwTag.ShouldNotBeNull();
126-
lwTag.CanonicalName.ShouldEqual("refs/tags/lw");
127-
lwTag.Target.ShouldNotBeNull();
128-
lwTag.Target.Sha.ShouldEqual("e90810b8df3e80c413d903f631643c716887138d");
129-
Assert.IsInstanceOf<Commit>(lwTag.Target);
105+
var annTag = (DirectReference) repo.Refs["refs/tags/test"];
106+
annTag.ShouldNotBeNull();
107+
annTag.CanonicalName.ShouldEqual("refs/tags/test");
108+
annTag.Target.ShouldNotBeNull();
109+
annTag.Target.Sha.ShouldEqual("b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
110+
Assert.IsInstanceOf<TagAnnotation>(annTag.Target);
130111
}
131112
}
132113

@@ -170,7 +151,7 @@ public void CreateWithNullForTargetThrows()
170151
using (var path = new TemporaryCloneOfTestRepo())
171152
using (var repo = new Repository(path.RepositoryPath))
172153
{
173-
Assert.Throws<ArgumentNullException>(() => repo.Refs.Create("refs/heads/newref", (string)null));
154+
Assert.Throws<ArgumentNullException>(() => repo.Refs.Create("refs/heads/newref", (string) null));
174155
}
175156
}
176157

@@ -184,6 +165,24 @@ public void CreateWithNullStringThrows()
184165
}
185166
}
186167

168+
[Test]
169+
public void DeleteWithEmptyNameThrows()
170+
{
171+
using (var repo = new Repository(Constants.TestRepoPath))
172+
{
173+
Assert.Throws<ArgumentException>(() => repo.Refs.Delete(string.Empty));
174+
}
175+
}
176+
177+
[Test]
178+
public void DeleteWithNullNameThrows()
179+
{
180+
using (var repo = new Repository(Constants.TestRepoPath))
181+
{
182+
Assert.Throws<ArgumentNullException>(() => repo.Refs.Delete(null));
183+
}
184+
}
185+
187186
[Test]
188187
public void ResolvingWithEmptyStringThrows()
189188
{

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ internal class NativeMethods
77
{
88
private const string libgit2 = "git2.dll";
99

10+
[DllImport(libgit2, SetLastError = true)]
11+
public static extern IntPtr git_blob_rawcontent(IntPtr blob);
12+
13+
[DllImport(libgit2, SetLastError = true)]
14+
public static extern int git_blob_rawsize(IntPtr blob);
15+
1016
[DllImport(libgit2, SetLastError = true)]
1117
public static extern IntPtr git_commit_author(IntPtr commit);
1218

@@ -107,7 +113,7 @@ internal class NativeMethods
107113
[DllImport(libgit2)]
108114
[return: MarshalAs(UnmanagedType.AnsiBStr)]
109115
public static extern string git_repository_path(RepositorySafeHandle repository);
110-
116+
111117
[DllImport(libgit2)]
112118
[return: MarshalAs(UnmanagedType.AnsiBStr)]
113119
public static extern string git_repository_workdir(RepositorySafeHandle repository);
@@ -152,36 +158,27 @@ internal class NativeMethods
152158

153159
[DllImport(libgit2, SetLastError = true)]
154160
public static extern IntPtr git_tag_target_oid(IntPtr tag);
155-
156-
/* Blob */
157-
[DllImport(libgit2, SetLastError = true)]
158-
public static extern int git_blob_rawsize(IntPtr blob);
159161

160162
[DllImport(libgit2, SetLastError = true)]
161-
public static extern IntPtr git_blob_rawcontent(IntPtr blob);
162-
163-
/* Tree */
163+
public static extern int git_tree_entry_2object(out IntPtr obj, RepositorySafeHandle repo, IntPtr entry);
164164

165165
[DllImport(libgit2, SetLastError = true)]
166-
[return: MarshalAs(UnmanagedType.AnsiBStr)]
167-
public static extern string git_tree_entry_name(IntPtr entry);
168-
166+
public static extern int git_tree_entry_attributes(IntPtr entry);
167+
169168
[DllImport(libgit2, SetLastError = true)]
170169
public static extern IntPtr git_tree_entry_byindex(IntPtr tree, int idx);
171170

172171
[DllImport(libgit2, SetLastError = true)]
173172
public static extern IntPtr git_tree_entry_byname(IntPtr tree, string filename);
174-
175-
[DllImport(libgit2, SetLastError = true)]
176-
public static extern int git_tree_entrycount(IntPtr tree);
177173

178174
[DllImport(libgit2, SetLastError = true)]
179175
public static extern IntPtr git_tree_entry_id(IntPtr tree);
180176

181177
[DllImport(libgit2, SetLastError = true)]
182-
public static extern int git_tree_entry_2object(out IntPtr obj, RepositorySafeHandle repo, IntPtr entry);
178+
[return: MarshalAs(UnmanagedType.AnsiBStr)]
179+
public static extern string git_tree_entry_name(IntPtr entry);
183180

184181
[DllImport(libgit2, SetLastError = true)]
185-
public static extern int git_tree_entry_attributes(IntPtr entry);
182+
public static extern int git_tree_entrycount(IntPtr tree);
186183
}
187184
}

LibGit2Sharp/ReferenceCollection.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public Reference this[string name]
3535
get { return Resolve<Reference>(name); }
3636
}
3737

38+
/// <summary>
39+
/// Shortcut to return the reference to HEAD
40+
/// </summary>
41+
/// <returns></returns>
42+
public Reference Head
43+
{
44+
get { return this[headReferenceName]; }
45+
}
46+
3847
#region IEnumerable<Reference> Members
3948

4049
public IEnumerator<Reference> GetEnumerator()
@@ -94,7 +103,7 @@ public Reference Create(string name, ObjectId target)
94103
}
95104

96105
/// <summary>
97-
/// Delete a reference with the specified name
106+
/// Delete a reference with the specified name
98107
/// </summary>
99108
public void Delete(string name)
100109
{
@@ -107,15 +116,6 @@ public void Delete(string name)
107116
Ensure.Success(res);
108117
}
109118

110-
/// <summary>
111-
/// Shortcut to return the reference to HEAD
112-
/// </summary>
113-
/// <returns></returns>
114-
public Reference Head
115-
{
116-
get { return this[headReferenceName]; }
117-
}
118-
119119
/// <summary>
120120
/// Gets the <see cref = "LibGit2Sharp.Reference" /> with the specified name.
121121
/// </summary>

0 commit comments

Comments
 (0)