Skip to content

Commit e320904

Browse files
yorahdahlbyk
authored andcommitted
Add SubmoduleLazyGroup
1 parent 4ef08c2 commit e320904

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

LibGit2Sharp/Core/GitObjectLazyGroup.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ namespace LibGit2Sharp.Core
55
{
66
internal class GitObjectLazyGroup : LazyGroup<GitObjectSafeHandle>
77
{
8-
private readonly Repository repo;
98
private readonly ObjectId id;
109

1110
public GitObjectLazyGroup(Repository repo, ObjectId id)
11+
: base(repo)
1212
{
13-
this.repo = repo;
1413
this.id = id;
1514
}
1615

LibGit2Sharp/Core/LazyGroup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ internal abstract class LazyGroup<T>
99
private readonly IList<IEvaluator<T>> evaluators = new List<IEvaluator<T>>();
1010
private readonly object @lock = new object();
1111
private bool evaluated;
12+
protected readonly Repository repo;
13+
14+
protected LazyGroup(Repository repo)
15+
{
16+
this.repo = repo;
17+
}
1218

1319
public ILazy<TResult> AddLazy<TResult>(Func<T, TResult> func)
1420
{
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using LibGit2Sharp.Core.Handles;
3+
4+
namespace LibGit2Sharp.Core
5+
{
6+
internal class SubmoduleLazyGroup : LazyGroup<SubmoduleSafeHandle>
7+
{
8+
private readonly string name;
9+
10+
public SubmoduleLazyGroup(Repository repo, string name)
11+
: base(repo)
12+
{
13+
this.name = name;
14+
}
15+
16+
protected override void EvaluateInternal(Action<SubmoduleSafeHandle> evaluator)
17+
{
18+
using (var handle = Proxy.git_submodule_lookup(repo.Handle, name))
19+
{
20+
evaluator(handle);
21+
}
22+
}
23+
}
24+
}

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<Compile Include="Core\Handles\GitFetchSpecHandle.cs" />
7373
<Compile Include="Core\PathCase.cs" />
7474
<Compile Include="Core\Handles\SubmoduleSafeHandle.cs" />
75+
<Compile Include="Core\SubmoduleLazyGroup.cs" />
7576
<Compile Include="Network.cs" />
7677
<Compile Include="Core\GitRemoteHead.cs" />
7778
<Compile Include="Stash.cs" />

0 commit comments

Comments
 (0)