mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 05:33:37 +00:00
Merge pull request #131 from adam111316/feature/AddPullRequestCheckout
Add pull request checkout option to General Config/Advanced Settings
This commit is contained in:
commit
4930a69798
6 changed files with 80 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
|||
* Add anime unit test cases (port from lad1337/sickbeard)
|
||||
* Fix normal tv show regex (port from midgetspy/sickbeard)
|
||||
* Fix anime regex (port from lad1337/sickbeard)
|
||||
* Add pull request checkout option to General Config/Advanced Settings
|
||||
|
||||
[develop changelog]
|
||||
|
||||
|
|
|
@ -461,6 +461,24 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
#set pulls = sickbeard.versionCheckScheduler.action.list_remote_pulls()
|
||||
#if len(pulls) > 0 and $sickbeard.BRANCH != 'master':
|
||||
<div class="field-pair">
|
||||
<label>
|
||||
<span class="component-title">Pull request:</span>
|
||||
<span class="component-desc">
|
||||
<select id="pullRequestVersion" class="form-control form-control-inline input-sm pull-left">
|
||||
#for $cur_branch in $pulls:
|
||||
<option value="$cur_branch.fetch_name()" #if $cur_branch == $sickbeard.BRANCH then 'selected="selected"' else ''#>$cur_branch</option>
|
||||
#end for
|
||||
</select>
|
||||
<input class="btn btn-inline" style="margin-left: 6px;" type="button" id="pullRequestCheckout" value="Checkout Pull Request">
|
||||
<div class="clear-left"><p>select pull request to test (restart required)</p></div>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
#end if
|
||||
|
||||
<div class="field-pair">
|
||||
<label for="git_remote">
|
||||
<span class="component-title">Git remote for branch</span>
|
||||
|
|
|
@ -113,6 +113,10 @@ $(document).ready(function(){
|
|||
$('#branchCheckout').click(function(){
|
||||
window.location.href = sbRoot + '/home/branchCheckout?branch=' + $('#branchVersion').val();
|
||||
});
|
||||
|
||||
$('#pullRequestCheckout').click(function(){
|
||||
window.location.href = sbRoot + '/home/pullRequestCheckout?branch=' + $('#pullRequestVersion').val();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -92,4 +92,27 @@ class GitHub(object):
|
|||
access_API = self._access_API(
|
||||
['repos', self.github_repo_user, self.github_repo, 'branches'],
|
||||
params={'per_page': 100})
|
||||
return access_API
|
||||
return access_API
|
||||
|
||||
def pull_requests(self):
|
||||
access_API = self._access_API(
|
||||
['repos', self.github_repo_user, self.github_repo, 'pulls'],
|
||||
params={'per_page': 100})
|
||||
pull = []
|
||||
for x in access_API:
|
||||
try:
|
||||
pull.append(PullRequest(x['head']['ref'], x['number']))
|
||||
except:
|
||||
continue
|
||||
return pull
|
||||
|
||||
class PullRequest(object):
|
||||
def __init__(self, ref, number):
|
||||
self.ref = ref
|
||||
self.number = number
|
||||
|
||||
def __repr__(self):
|
||||
return '%s: %s' % (self.number, self.ref)
|
||||
|
||||
def fetch_name(self):
|
||||
return 'pull/%s/head:pull/%s/%s' % (self.number, self.number, self.ref)
|
|
@ -115,9 +115,15 @@ class CheckVersion():
|
|||
if self.updater.need_update():
|
||||
return self.updater.update()
|
||||
|
||||
def fetch(self, pull_request):
|
||||
return self.updater.fetch(pull_request)
|
||||
|
||||
def list_remote_branches(self):
|
||||
return self.updater.list_remote_branches()
|
||||
|
||||
def list_remote_pulls(self):
|
||||
return self.updater.list_remote_pulls()
|
||||
|
||||
def get_branch(self):
|
||||
return self.updater.branch
|
||||
|
||||
|
@ -400,6 +406,17 @@ class GitUpdateManager(UpdateManager):
|
|||
return re.findall('\S+\Wrefs/heads/(.*)', branches)
|
||||
return []
|
||||
|
||||
def list_remote_pulls(self):
|
||||
gh = github.GitHub(self.github_repo_user, self.github_repo, self.branch)
|
||||
return gh.pull_requests()
|
||||
|
||||
def fetch(self, pull_request):
|
||||
output, err, exit_status = self._run_git(self._git_path, 'fetch -f %s %s' % (sickbeard.GIT_REMOTE, pull_request)) # @UnusedVariable
|
||||
if exit_status == 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
class SourceUpdateManager(UpdateManager):
|
||||
def __init__(self):
|
||||
|
@ -596,4 +613,8 @@ class SourceUpdateManager(UpdateManager):
|
|||
|
||||
def list_remote_branches(self):
|
||||
gh = github.GitHub(self.github_repo_user, self.github_repo, self.branch)
|
||||
return [x['name'] for x in gh.branches() if x and 'name' in x]
|
||||
return [x['name'] for x in gh.branches() if x and 'name' in x]
|
||||
|
||||
def list_remote_pulls(self):
|
||||
# we don't care about testers that don't use git
|
||||
return []
|
|
@ -3628,6 +3628,17 @@ class Home(MainHandler):
|
|||
ui.notifications.message('Checking out branch: ', branch)
|
||||
return self.update(sickbeard.PID)
|
||||
|
||||
def pullRequestCheckout(self, branch):
|
||||
pull_request = branch
|
||||
branch = branch.split(':')[1]
|
||||
fetched = sickbeard.versionCheckScheduler.action.fetch(pull_request)
|
||||
if fetched:
|
||||
sickbeard.BRANCH = branch
|
||||
ui.notifications.message('Checking out branch: ', branch)
|
||||
return self.update(sickbeard.PID)
|
||||
else:
|
||||
return redirect('/home/')
|
||||
|
||||
def displayShow(self, show=None):
|
||||
|
||||
if show is None:
|
||||
|
|
Loading…
Reference in a new issue