Allow for test generation using commit SHAs
This commit is contained in:
1 parent
3933e4980b
commit
6309183838
1 file changed
+11
-6
+11
-6
@@ -184,17 +184,22 @@ def verifyNewTest(request):
|
|||||||
|
|
||||||
def getBranchInformation(repo, branch, errors):
|
def getBranchInformation(repo, branch, errors):
|
||||||
|
|
||||||
|
bysha = bool(re.search('[0-9a-fA-F]{40}', branch))
|
||||||
|
url = 'commits' if bysha else 'branches'
|
||||||
|
|
||||||
target = repo.replace('github.com', 'api.github.com/repos')
|
target = repo.replace('github.com', 'api.github.com/repos')
|
||||||
target = pathjoin(target, 'branches', branch)
|
target = pathjoin(target, url, branch).rstrip('/')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = requests.get(target.rstrip('/')).json()
|
data = requests.get(target).json()
|
||||||
treesha = data['commit']['commit']['tree']['sha']
|
data = data if bysha else data['commit']
|
||||||
source = pathjoin(repo, 'archive', treesha + '.zip').rstrip('/')
|
|
||||||
return (data['commit']['sha'], source)
|
treeurl = data['commit']['tree']['sha'] + '.zip'
|
||||||
|
return (data['sha'], pathjoin(repo, 'archive', treeurl).rstrip('/'))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
errors.append("Branch {0} could not be found".format(branch))
|
lookup = 'Commit Sha' if bysha else 'Branch'
|
||||||
|
errors.append('{0} {1} could not be found'.format(lookup, branch))
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
def createNewTest(request):
|
def createNewTest(request):
|
||||||
|
|||||||
Reference in new issue
Block a user