Skip to content

Commit dd48183

Browse files
committed
fixing repo_url parsing to get correct bucket
1 parent 8439032 commit dd48183

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

singularity/build/google.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ def list_bucket(bucket,storage_service):
135135
return objects
136136

137137

138+
def get_image_path(repo_url,commit):
139+
'''get_image_path will determine an image path based on a repo url, removing
140+
any token, and taking into account urls that end with .git.
141+
:param repo_url: the repo url to parse:
142+
:param commit: the commit to use
143+
'''
144+
repo_url = repo_url.split('@')[-1].strip()
145+
if repo_url.endswith('.git'):
146+
repo_url = repo_url[:-4]
147+
return "%s/%s" %(re.sub('^http.+//www[.]','',repo_url),commit)
148+
149+
138150

139151
def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,bucket_name=None,
140152
repo_id=None,commit=None,verbose=True,response_url=None,secret=None,branch=None,
@@ -230,7 +242,8 @@ def run_build(build_dir=None,spec_file=None,repo_url=None,token=None,size=None,b
230242
zf.extractall(dest_dir)
231243

232244
# The path to the images on google drive will be the github url/commit folder
233-
image_path = "%s/%s" %(re.sub('^http.+//www[.]','',params['repo_url']),params['commit'])
245+
image_path = get_image_path(params['repo_url'],params['commit'])
246+
234247
build_files = glob("%s/*" %(dest_dir))
235248
build_files.append(compressed_image)
236249
bot.logger.info("Sending build files %s to storage",'\n'.join(build_files))
@@ -304,8 +317,8 @@ def finish_build(verbose=True):
304317
# Start the storage service, retrieve the bucket
305318
storage_service = get_google_service()
306319
bucket = get_bucket(storage_service,params['bucket_name'])
307-
image_path = "%s/%s" %(re.sub('^http.+//www[.]','',params['repo_url']),params['commit'])
308-
320+
image_path = get_image_path(params['repo_url'],params['commit'])
321+
309322
# Upload the log file
310323
params['log_file'] = upload_file(storage_service,
311324
bucket=bucket,

0 commit comments

Comments
 (0)