Skip to content

Commit

Permalink
Revert "Added support for Github Enterprise instances (#1972)"
Browse files Browse the repository at this point in the history
This reverts commit 7ebc882.
  • Loading branch information
cutwater committed Apr 23, 2020
1 parent ddae14d commit ff6c5b3
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 61 deletions.
1 change: 0 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Christopher Chase <[email protected]>
David Newswanger <[email protected]>
David Zager <[email protected]>
Dostonbek <[email protected]>
Egor Margineanu <[email protected]>
Ivan <[email protected]>
Ivan Remizov <[email protected]>
James Cammarata <[email protected]>
Expand Down
4 changes: 1 addition & 3 deletions galaxy/api/githubapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from allauth.socialaccount.models import SocialToken
from django.core.exceptions import ObjectDoesNotExist
from galaxy.common.github import get_github_api_url
from galaxy.main.models import Provider


Expand Down Expand Up @@ -59,8 +58,7 @@ def get_client(self):
"User does not have a GitHub OAuth token"
)
try:
client = Github(base_url=get_github_api_url(),
login_or_token=gh_token.token)
client = Github(gh_token.token)
except GithubException as exc:
raise Exception("Failed to connect to the GitHub API {0} - {1}"
.format(exc.data, exc.status))
Expand Down
6 changes: 4 additions & 2 deletions galaxy/api/serializers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from django.urls import reverse
from rest_framework import serializers as drf_serializers

from galaxy.common.github import get_github_web_url
from galaxy.main.models import Repository
from . import serializers

Expand Down Expand Up @@ -165,8 +164,11 @@ def get_summary_fields(self, instance):
}

def get_external_url(self, instance):
server = ''
if instance.provider_namespace.provider.name.lower() == 'github':
server = 'https://github.com'
return '{0}/{1}/{2}'.format(
get_github_web_url(),
server,
instance.provider_namespace.name,
instance.original_name)

Expand Down
1 change: 0 additions & 1 deletion galaxy/api/serializers/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class BaseRoleSerializer(BaseSerializer):
REPOSITORY_MOVED_FIELDS = (
'github_user',
'github_repo',
'github_server',
('github_branch', 'import_branch'),
'stargazers_count',
'forks_count',
Expand Down
6 changes: 3 additions & 3 deletions galaxy/api/views/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import requests

from allauth.socialaccount.models import SocialAccount
from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied

Expand All @@ -13,7 +14,6 @@

from galaxy.api.views import base_views
from galaxy.api.serializers import TokenSerializer
from galaxy.common.github import get_github_api_url

__all__ = [
'TokenView',
Expand Down Expand Up @@ -76,7 +76,7 @@ def post(self, request, *args, **kwargs):
raise ValidationError({'detail': "Invalid request."})

try:
git_status = requests.get(get_github_api_url())
git_status = requests.get(settings.GITHUB_SERVER)
git_status.raise_for_status()
except Exception:
raise ValidationError({
Expand All @@ -86,7 +86,7 @@ def post(self, request, *args, **kwargs):
try:
header = dict(Authorization='token ' + github_token)
gh_user = requests.get(
get_github_api_url() + '/user', headers=header
settings.GITHUB_SERVER + '/user', headers=header
)
gh_user.raise_for_status()
gh_user = gh_user.json()
Expand Down
36 changes: 0 additions & 36 deletions galaxy/common/github.py

This file was deleted.

8 changes: 1 addition & 7 deletions galaxy/main/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from django.urls import reverse

from galaxy import constants
from galaxy.common.github import get_github_web_url
from galaxy.main import fields

from .base import BaseModel
Expand Down Expand Up @@ -107,8 +106,7 @@ class Meta:

@property
def clone_url(self):
return "{server}/{user}/{repo}.git".format(
server=get_github_web_url(),
return "https://github.com/{user}/{repo}.git".format(
user=self.provider_namespace.name,
repo=self.original_name
)
Expand All @@ -121,10 +119,6 @@ def github_user(self):
def github_repo(self):
return self.original_name

@property
def github_server(self):
return get_github_web_url()

@property
def content_counts(self):
return Content.objects \
Expand Down
12 changes: 4 additions & 8 deletions galaxy/worker/tasks/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from allauth.socialaccount import models as auth_models

from galaxy import constants
from galaxy.common.github import get_github_api_url
from galaxy.importer import repository as i_repo
from galaxy.importer import exceptions as i_exc
from galaxy.main import models
Expand Down Expand Up @@ -91,15 +90,12 @@ def _import_repository(import_task, logger):
logger.info(' ')

token = _get_social_token(import_task)
gh_api = github.Github(base_url=get_github_api_url(),
login_or_token=token)
gh_api = github.Github(token)
gh_repo = gh_api.get_repo(repo_full_name)

try:
repo_info = i_repo.import_repository(
gh_repo.clone_url.replace("https://", "https://{token}@".format(
token=token
)),
repository.clone_url,
branch=import_task.import_branch,
temp_dir=settings.CONTENT_DOWNLOAD_DIR,
logger=logger)
Expand Down Expand Up @@ -319,8 +315,8 @@ def _update_repo_info(repository, gh_repo, commit_info, repo_description):
repository.commit = commit_info.sha
repository.commit_message = commit_info.message[:255]
repository.commit_url = \
'{0}/repos/{1}/git/commits/{2}'.format(
get_github_api_url(), gh_repo.full_name, commit_info.sha)
'https://api.github.com/repos/{0}/git/commits/{1}'.format(
gh_repo.full_name, commit_info.sha)
repository.commit_created = commit_info.committer_date


Expand Down

0 comments on commit ff6c5b3

Please sign in to comment.