8000 Introduce MergeFetchHeadNotFoundException · coding2233/libgit2sharp4unity3d@c8e7be6 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8e7be6

Browse files
committed
Introduce MergeFetchHeadNotFoundException
This adds a strongly typed exception to indicate when a pull is performed and a reference for the configured merge branch was not fetched.
1 parent 0e5bfbc commit c8e7be6

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<Compile Include="PushOptions.cs" />
125125
<Compile Include="Core\GitBuf.cs" />
126126
<Compile Include="FilteringOptions.cs" />
127+
<Compile Include="MergeFetchHeadNotFoundException.cs" />
127128
<Compile Include="ResetMode.cs" />
128129
<Compile Include="NoteCollectionExtensions.cs" />
129130
<Compile Include="RefSpecDirection.cs" />
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
using LibGit2Sharp.Core;
4+
5+
namespace LibGit2Sharp
6+
{
7+
/// <summary>
8+
/// The exception that is thrown when the ref to merge with was as part of a pull operation not fetched.
9+
/// </summary>
10+
[Serializable]
11+
public class MergeFetchHeadNotFoundException : NotFoundException
12+
{
13+
/// <summary>
14+
/// Initializes a new instance of the <see cref="MergeFetchHeadNotFoundException"/> class.
15+
/// </summary>
16+
public MergeFetchHeadNotFoundException()
17+
{
18+
}
19+
20+
/// <summary>
21+
/// Initializes a new instance of the <see cref="MergeFetchHeadNotFoundException"/> class with a specified error message.
22+
/// </summary>
23+
/// <param name="message">A message that describes the error.</param>
24+
public MergeFetchHeadNotFoundException(string message)
25+
: base(message)
26+
{
27+
}
28+
29+
/// <summary>
30+
/// Initializes a new instance of the <see cref="MergeFetchHeadNotFoundException"/> class with a specified error message and a reference to the inner exception that is the cause of this exception.
31+
/// </summary>
32+
/// <param name="message">The error message that explains the reason for the exception.</param>
33+
/// <param name="innerException">The exception that is the cause of the current exception. If the <paramref name="innerException"/> parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.</param>
34+
public MergeFetchHeadNotFoundException(string message, Exception innerException)
35+
: base(message, innerException)
36+
{
37+
}
38+
39+
/// <summary>
40+
/// Initializes a new instance of the <see cref="MergeFetchHeadNotFoundException"/> class with a serialized data.
41+
/// </summary>
42+
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
43+
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
44+
protected MergeFetchHeadNotFoundException(SerializationInfo info, StreamingContext context)
45+
: base(info, context)
46+
{
47+
}
48+
}
49+
}

LibGit2Sharp/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ internal MergeResult MergeFetchHeads(Signature merger, MergeOptions options)
10321032

10331033
if (fetchHeads.Length == 0)
10341034
{
1035-
throw new LibGit2SharpException("Remote ref to merge from was not fetched.");
1035+
throw new MergeFetchHeadNotFoundException("The configured reference to merge with was not fetched from the remote.");
10361036
}
10371037

10381038
GitMergeHeadHandle[] mergeHeadHandles = fetchHeads.Select(fetchHead =>

0 commit comments

Comments
 (0)
0