Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 7cb5669

Browse files
committed
Add helper for checking whether a repo has commits
I'm doing it this way instead of calling GetRepoFromPath directly from the calling site because I don't want GitHub.VisualStudio to have an explicit reference to libgit2sharp, and I'm not sure if I want to add this to the ISimpleRepositoryModel interface.
1 parent 57a9cad commit 7cb5669

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/GitHub.Exports/Services/Services.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,11 @@ public static UriString GetUriFromRepository(this IGitRepositoryInfo repoInfo)
180180
{
181181
return repoInfo.GetRepoFromIGit()?.GetUri();
182182
}
183+
184+
public static bool HasCommits(this ISimpleRepositoryModel repository)
185+
{
186+
var repo = GetRepoFromPath(repository.LocalPath);
187+
return repo?.Commits.Count() > 0;
188+
}
183189
}
184190
}

0 commit comments

Comments
 (0)