Handle both a trailing and non-trailing '/' in source paths

This commit is contained in:
AndyGrant committed 2020-03-19 12:33:57 -04:00
1 parent cc288cae93
commit 753242948b
2 files changed
+27 -4

No files matched your search

+25 -3
View File
@@ -1,3 +1,25 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# OpenBench is a chess engine testing framework authored by Andrew Grant. #
# <https://github.com/AndyGrant/OpenBench> <andrew@grantnet.us> #
# #
# OpenBench is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# OpenBench is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import OpenBench.utils
from django import template
from OpenBench.models import Test
@@ -39,9 +61,9 @@ def gitDiffLink(test):
devsha = test.dev.sha
basesha = test.base.sha
repo = '/'.join(dev.split('/')[:-2])
return '{0}/compare/{1}...{2}'.format(repo, basesha[:8], devsha[:8])
repo = OpenBench.utils.pathjoin(*dev.split('/')[:-2])
return OpenBench.utils.pathjoin(repo, 'compare',
'{0}...{1}'.format(basesha[:8], devsha[:8]))
def shortStatBlock(test):
+2 -1
View File
@@ -192,7 +192,8 @@ def getBranchInformation(repo, branch, errors):
try:
data = requests.get(target.rstrip('/')).json()
treesha = data['commit']['commit']['tree']['sha']
return (data['commit']['sha'], pathjoin(repo, 'archive', treesha, '.zip'))
source = pathjoin(repo, 'archive', treesha + '.zip').rstrip('/')
return (data['commit']['sha'], source)
except:
errors.append("Branch {0} could not be found".format(branch))