mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Merge branch 'gitignore-exception'
This commit is contained in:
@@ -188,6 +188,25 @@ public class RepositoriesClientTests
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ThrowsInvalidGitIgnoreExceptionForInvalidTemplateNames()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("repo-with-gitignore");
|
||||
|
||||
var newRepository = new NewRepository(repoName)
|
||||
{
|
||||
AutoInit = true,
|
||||
GitignoreTemplate = "visualstudio"
|
||||
};
|
||||
|
||||
var thrown = await Assert.ThrowsAsync<InvalidGitIgnoreTemplateException>(
|
||||
() => github.CreateRepositoryContext(newRepository));
|
||||
|
||||
Assert.NotNull(thrown);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ThrowsRepositoryExistsExceptionForExistingRepository()
|
||||
{
|
||||
|
||||
@@ -116,6 +116,12 @@ namespace Octokit
|
||||
{
|
||||
throw new PrivateRepositoryQuotaExceededException(e);
|
||||
}
|
||||
|
||||
if (errorMessage != null && errorMessage.EndsWith("is an unknown gitignore template.", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new InvalidGitIgnoreTemplateException(e);
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
58
Octokit/Exceptions/InvalidGitignoreTemplateException.cs
Normal file
58
Octokit/Exceptions/InvalidGitignoreTemplateException.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a HTTP 403 - Forbidden response returned from the API.
|
||||
/// </summary>
|
||||
#if !NETFX_CORE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class InvalidGitIgnoreTemplateException : ApiValidationException
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs an instance of ApiValidationException
|
||||
/// </summary>
|
||||
public InvalidGitIgnoreTemplateException()
|
||||
: base() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an instance of ApiValidationException
|
||||
/// </summary>
|
||||
/// <param name="innerException">The inner validation exception.</param>
|
||||
public InvalidGitIgnoreTemplateException(ApiValidationException innerException)
|
||||
: base(innerException) { }
|
||||
|
||||
public override string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return "The Gitignore template provided is not valid.";
|
||||
}
|
||||
}
|
||||
|
||||
#if !NETFX_CORE
|
||||
/// <summary>
|
||||
/// Constructs an instance of InvalidGitignoreTemplateException
|
||||
/// </summary>
|
||||
/// <param name="info">
|
||||
/// The <see cref="SerializationInfo"/> that holds the
|
||||
/// serialized object data about the exception being thrown.
|
||||
/// </param>
|
||||
/// <param name="context">
|
||||
/// The <see cref="StreamingContext"/> that contains
|
||||
/// contextual information about the source or destination.
|
||||
/// </param>
|
||||
protected InvalidGitIgnoreTemplateException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) { }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -404,6 +404,7 @@
|
||||
<Compile Include="Http\IApiInfoProvider.cs" />
|
||||
<Compile Include="Models\Response\Meta.cs" />
|
||||
<Compile Include="Models\Common\Committer.cs" />
|
||||
<Compile Include="Exceptions\InvalidGitIgnoreTemplateException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -412,6 +412,7 @@
|
||||
<Compile Include="Models\Response\Meta.cs" />
|
||||
<Compile Include="Models\Common\Committer.cs" />
|
||||
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
|
||||
<Compile Include="Exceptions\InvalidGitIgnoreTemplateException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -408,7 +408,8 @@
|
||||
<Compile Include="Models\Response\Meta.cs" />
|
||||
<Compile Include="Models\Common\Committer.cs" />
|
||||
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
|
||||
<Compile Include="Exceptions\InvalidGitIgnoreTemplateException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -401,6 +401,7 @@
|
||||
<Compile Include="Http\IApiInfoProvider.cs" />
|
||||
<Compile Include="Models\Response\Meta.cs" />
|
||||
<Compile Include="Models\Common\Committer.cs" />
|
||||
<Compile Include="Exceptions\InvalidGitIgnoreTemplateException.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -405,6 +405,7 @@
|
||||
<Compile Include="Models\Response\Meta.cs" />
|
||||
<Compile Include="Models\Common\Committer.cs" />
|
||||
<Compile Include="Models\Request\NewArbitraryMarkDown.cs" />
|
||||
<Compile Include="Exceptions\InvalidGitIgnoreTemplateException.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
<Compile Include="Clients\RepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\UserKeysClient.cs" />
|
||||
<Compile Include="Clients\RepositoryContentsClient.cs" />
|
||||
<Compile Include="Exceptions\InvalidGitIgnoreTemplateException.cs" />
|
||||
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
|
||||
<Compile Include="Exceptions\RepositoryExistsException.cs" />
|
||||
<Compile Include="Exceptions\RepositoryFormatException.cs" />
|
||||
|
||||
Reference in New Issue
Block a user