コード例 #1
0
        bool EnterpriseWorkaround(UriString hostAddress, Exception e)
        {
            // Older Enterprise hosts either don't have the API end-point to PUT an authorization, or they
            // return 422 because they haven't white-listed our client ID. In that case, we just ignore
            // the failure, using basic authentication (with username and password) instead of trying
            // to get an authorization token.
            var apiException = e as ApiException;

            return(!HostAddress.IsGitHubDotComUri(hostAddress.ToUri()) &&
                   (e is NotFoundException ||
                    e is ForbiddenException ||
                    apiException?.StatusCode == (HttpStatusCode)422));
        }
コード例 #2
0
        private async Task <Octokit.Repository> GetRepositoryInternal()
        {
            try
            {
                if (owner == null)
                {
                    var ownerLogin     = OriginalUrl.Owner;
                    var repositoryName = OriginalUrl.RepositoryName;

                    if (ownerLogin != null && repositoryName != null)
                    {
                        var repo = await githubClient.Repository.Get(ownerLogin, repositoryName);

                        if (repo != null)
                        {
                            repositoryCache = repo;
                        }
                        owner = ownerLogin;
                    }
                }
            }
            // it'll throw if it's private or an enterprise instance requiring authentication
            catch (ApiException apiex)
            {
                if (!HostAddress.IsGitHubDotComUri(OriginalUrl.ToRepositoryUri()))
                {
                    isEnterprise = apiex.IsGitHubApiException();
                }
            }
            catch {}
            finally
            {
                sem.Release();
            }

            return(repositoryCache);
        }