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

Commit 1b8e445

Browse files
committed
update documentation and handle when repo is null
1 parent c4dac97 commit 1b8e445

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/GitHub.Exports/Services/GitService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,16 @@ public UriString GetRemoteUri(IRepository repo, string remote = "origin")
7777
/// Finds the latest pushed commit of a file and returns the sha of that commit. Returns null when no commits have
7878
/// been found in any remote branches or the current local branch.
7979
/// </summary>
80-
/// <param name="path">The local path of the file. This cannot be null.</param>
80+
/// <param name="path">The local path of a repository or a file inside a repository. This cannot be null.</param>
8181
/// <returns></returns>
8282
public Task<string> GetLatestPushedSha(string path)
8383
{
8484
Guard.ArgumentNotNull(path, nameof(path));
8585
var repo = GetRepository(path);
8686

87+
if (repo == null)
88+
return null;
89+
8790
if (repo.Head.IsTracking && repo.Head.Tip.Sha == repo.Head.TrackedBranch.Tip.Sha)
8891
{
8992
return Task.FromResult(repo.Head.Tip.Sha);

src/GitHub.Exports/Services/IGitService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public interface IGitService
4646
/// <returns></returns>
4747
UriString GetRemoteUri(IRepository repo, string remote = "origin");
4848

49+
/// <summary>
50+
/// Finds the latest pushed commit of a file and returns the sha of that commit. Returns null when no commits have
51+
/// been found in any remote branches or the current local branch.
52+
/// </summary>
53+
/// <param name="path">The local path of a repository or a file inside a repository. This cannot be null.</param>
54+
/// <returns></returns>
4955
Task<string> GetLatestPushedSha(string path);
5056
}
5157
}

0 commit comments

Comments
 (0)