Refined logic for locating git branch inside ReadTheDocs (#3573)

This commit is contained in:
Philip Hyunsu Cho 2018-08-09 15:28:12 -07:00 committed by GitHub
parent aa4ee6a0e4
commit 2e7c3a0ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,12 +16,15 @@ from sh.contrib import git
import urllib.request import urllib.request
from recommonmark.parser import CommonMarkParser from recommonmark.parser import CommonMarkParser
import sys import sys
import re
import os, subprocess import os, subprocess
import shlex import shlex
import guzzle_sphinx_theme import guzzle_sphinx_theme
git_branch = str(git('rev-parse', '--abbrev-ref', 'HEAD')).rstrip('\n') git_branch = [re.sub(r'origin/', '', x.lstrip(' ')) for x in str(git.branch('-r', '--contains', 'HEAD')).rstrip('\n').split('\n')]
filename, _ = urllib.request.urlretrieve('https://s3-us-west-2.amazonaws.com/xgboost-docs/{}.tar.bz2'.format(git_branch)) git_branch = [x for x in git_branch if 'HEAD' not in x]
print('git_branch = {}'.format(git_branch[0]))
filename, _ = urllib.request.urlretrieve('https://s3-us-west-2.amazonaws.com/xgboost-docs/{}.tar.bz2'.format(git_branch[0]))
call('if [ -d tmp ]; then rm -rf tmp; fi; mkdir -p tmp/jvm; cd tmp/jvm; tar xvf {}'.format(filename), shell=True) call('if [ -d tmp ]; then rm -rf tmp; fi; mkdir -p tmp/jvm; cd tmp/jvm; tar xvf {}'.format(filename), shell=True)
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,