Skip to content

Commit 34779a2

Browse files
committed
Make PackBuilder methods chainable
1 parent 7b8e982 commit 34779a2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

LibGit2Sharp/PackBuilder.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ internal PackBuilder(Repository repository)
3030
/// </summary>
3131
/// <param name="gitObject">The object to be inserted.</param>
3232
/// <exception cref="ArgumentNullException">if the gitObject is null</exception>
33-
public void Add<T>(T gitObject) where T : GitObject
33+
public PackBuilder Add<T>(T gitObject) where T : GitObject
3434
{
3535
Ensure.ArgumentNotNull(gitObject, "gitObject");
3636

3737
Add(gitObject.Id);
38+
39+
return this;
3840
}
3941

4042
/// <summary>
@@ -43,11 +45,13 @@ public void Add<T>(T gitObject) where T : GitObject
4345
/// </summary>
4446
/// <param name="gitObject">The object to be inserted recursively.</param>
4547
/// <exception cref="ArgumentNullException">if the gitObject is null</exception>
46-
public void AddRecursively<T>(T gitObject) where T : GitObject
48+
public PackBuilder AddRecursively<T>(T gitObject) where T : GitObject
4749
{
4850
Ensure.ArgumentNotNull(gitObject, "gitObject");
4951

5052
AddRecursively(gitObject.Id);
53+
54+
return this;
5155
}
5256

5357
/// <summary>
@@ -56,11 +60,13 @@ public void AddRecursively<T>(T gitObject) where T : GitObject
5660
/// </summary>
5761
/// <param name="id">The object ID to be inserted.</param>
5862
/// <exception cref="ArgumentNullException">if the id is null</exception>
59-
public void Add(ObjectId id)
63+
public PackBuilder Add(ObjectId id)
6064
{
6165
Ensure.ArgumentNotNull(id, "id");
6266

6367
Proxy.git_packbuilder_insert(packBuilderHandle, id, null);
68+
69+
return this;
6470
}
6571

6672
/// <summary>
@@ -69,11 +75,13 @@ public void Add(ObjectId id)
6975
/// </summary>
7076
/// <param name="id">The object ID to be recursively inserted.</param>
7177
/// <exception cref="ArgumentNullException">if the id is null</exception>
72-
public void AddRecursively(ObjectId id)
78+
public PackBuilder AddRecursively(ObjectId id)
7379
{
7480
Ensure.ArgumentNotNull(id, "id");
7581

7682
Proxy.git_packbuilder_insert_recur(packBuilderHandle, id, null);
83+
84+
return this;
7785
}
7886

7987
/// <summary>

0 commit comments

Comments
 (0)