Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit abcd6c9

Browse files
Merge branch 'master' into fixes/cannot-move-octorun
2 parents 72e6d18 + e2f8c62 commit abcd6c9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/GitHub.Api/Git/GitClient.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ public ITask<GitAheadBehindStatus> AheadBehindStatus(string gitRef, string other
325325
public ITask<List<GitLogEntry>> Log(BaseOutputListProcessor<GitLogEntry> processor = null)
326326
{
327327
return new GitLogTask(new GitObjectFactory(environment), cancellationToken, processor)
328-
.Configure(processManager);
328+
.Configure(processManager)
329+
.Catch(exception => exception is ProcessException &&
330+
exception.Message.StartsWith("fatal: your current branch") &&
331+
exception.Message.EndsWith("does not have any commits yet"))
332+
.Then((success, list) => success ? list : new List<GitLogEntry>());
329333
}
330334

331335
///<inheritdoc/>
@@ -596,7 +600,11 @@ public ITask<string> Unlock(NPath file, bool force,
596600
public ITask<string> GetHead(IOutputProcessor<string> processor = null)
597601
{
598602
return new FirstNonNullLineProcessTask(cancellationToken, "rev-parse --short HEAD") { Name = "Getting current head..." }
599-
.Configure(processManager);
603+
.Configure(processManager)
604+
.Catch(exception => exception is ProcessException &&
605+
exception.Message.StartsWith("fatal: your current branch") &&
606+
exception.Message.EndsWith("does not have any commits yet"))
607+
.Then((success, head) => success ? head : null);
600608
}
601609

602610
protected static ILogging Logger { get; } = LogHelper.GetLogger<GitClient>();

0 commit comments

Comments
 (0)