Skip to content

Commit 07419b2

Browse files
committed
Add Submodule.GitLink
1 parent 2ab7ce4 commit 07419b2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

LibGit2Sharp/Submodule.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Diagnostics;
33
using System.Globalization;
44
using LibGit2Sharp.Core;
5+
using LibGit2Sharp.Core.Compat;
56

67
namespace LibGit2Sharp
78
{
@@ -18,6 +19,7 @@ public class Submodule : IEquatable<Submodule>
1819
private readonly string name;
1920
private readonly string path;
2021
private readonly string url;
22+
private readonly Lazy<GitLink> gitLink;
2123
private readonly ILazy<ObjectId> headCommitId;
2224
private readonly ILazy<ObjectId> indexCommitId;
2325
private readonly ILazy<ObjectId> workdirCommitId;
@@ -38,6 +40,8 @@ internal Submodule(Repository repo, string name, string path, string url)
3840
this.path = path;
3941
this.url = url;
4042

43+
gitLink = new Lazy<GitLink>(() => new GitLink(repo, HeadCommitId));
44+
4145
var commitIds = new SubmoduleLazyGroup(repo, name);
4246
headCommitId = commitIds.AddLazy(Proxy.git_submodule_head_id);
4347
indexCommitId = commitIds.AddLazy(Proxy.git_submodule_index_id);
@@ -64,6 +68,11 @@ internal Submodule(Repository repo, string name, string path, string url)
6468
/// </summary>
6569
public virtual string Url { get { return url; } }
6670

71+
/// <summary>
72+
/// The gitlink representing this submodule in the current HEAD tree.
73+
/// </summary>
74+
public virtual GitLink GitLink { get { return gitLink.Value; } }
75+
6776
/// <summary>
6877
/// The commit ID for this submodule in the current HEAD tree.
6978
/// </summary>

0 commit comments

Comments
 (0)