Skip to content

Commit

Permalink
ARROW-3572: [Crossbow] Raise more helpful exception if Crossbow queue…
Browse files Browse the repository at this point in the history
… has an SSH origin URL

Author: Wes McKinney <wesm+git@apache.org>

Closes #4666 from wesm/ARROW-3572 and squashes the following commits:

867a156 <Wes McKinney> Raise more helpful exception if Crossbow queue has an SSH origin URL
  • Loading branch information
wesm committed Jun 24, 2019
1 parent 532d4ba commit ba4e0f3
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions dev/tasks/crossbow.py
Expand Up @@ -232,12 +232,17 @@ class Repo:
A high level wrapper used for both reading revision information from
arrow's repository and pushing continuous integration tasks to the queue
repository.
"""
def __init__(self, path, github_token=None):
Parameters
----------
require_https : boolean, default False
Raise exception for SSH origin URLs
"""
def __init__(self, path, github_token=None, require_https=False):
self.path = Path(path)
self.repo = pygit2.Repository(str(self.path))
self.github_token = github_token
self.require_https = require_https
self._updated_refs = []

def __str__(self):
Expand All @@ -253,7 +258,11 @@ def __str__(self):

@property
def origin(self):
return self.repo.remotes['origin']
remote = self.repo.remotes['origin']
if self.require_https and remote.url.startswith('git@github.com'):
raise ValueError("Change SSH origin URL to HTTPS to use "
"Crossbow: {}".format(remote.url))
return remote

def fetch(self):
refspec = '+refs/heads/*:refs/remotes/origin/*'
Expand Down Expand Up @@ -297,8 +306,7 @@ def remote_url(self):
If an SSH github url is set, it will be replaced by the https
equivalent usable with Github OAuth token.
"""
return self.remote.url.replace('git@github.com:',
'https://github.com/')
return _git_ssh_to_https(self.remote.url)

@property
def user_name(self):
Expand Down Expand Up @@ -385,6 +393,10 @@ def as_github_repo(self):
return gh.repository(username, reponame)


def _git_ssh_to_https(url):
return url.replace('git@github.com:', 'https://github.com/')


class Queue(Repo):

def _next_job_id(self, prefix):
Expand Down Expand Up @@ -631,8 +643,9 @@ def crossbow(ctx, github_token, arrow_path, queue_path):
'valid GitHub access token or pass one to --github-token.'
)

ctx.obj['arrow'] = Repo(Path(arrow_path))
ctx.obj['queue'] = Queue(Path(queue_path), github_token=github_token)
ctx.obj['arrow'] = Repo(arrow_path)
ctx.obj['queue'] = Queue(queue_path, github_token=github_token,
require_https=True)


@crossbow.command()
Expand Down

0 comments on commit ba4e0f3

Please sign in to comment.