treat argument as a project reference, allowed to be a URI (#44111)
This commit is contained in:
parent
d87b09c43a
commit
bea756e1c5
|
@ -7,6 +7,7 @@ import subprocess
|
|||
import sys
|
||||
import tarfile
|
||||
import time
|
||||
import urllib.parse
|
||||
import os
|
||||
|
||||
from eobuilder import settings, VERSION, init
|
||||
|
@ -401,8 +402,21 @@ def clean_git_on_exit(git_project_path):
|
|||
if os.path.exists(changelog_tmp):
|
||||
os.remove(changelog_tmp)
|
||||
|
||||
def setup_git_tree(project_name, options):
|
||||
git_project_path = os.path.join(settings.GIT_PATH, os.path.basename(project_name))
|
||||
|
||||
def get_git_project_name(project_reference):
|
||||
project_name = os.path.basename(project_reference)
|
||||
if project_name.endswith('.git'):
|
||||
project_name = project_name[:-4]
|
||||
return project_name
|
||||
|
||||
|
||||
def get_git_project_path(project_reference):
|
||||
return os.path.join(settings.GIT_PATH, get_git_project_name(project_reference))
|
||||
|
||||
|
||||
def setup_git_tree(project_reference, options):
|
||||
project_name = get_git_project_name(project_reference)
|
||||
git_project_path = get_git_project_path(project_reference)
|
||||
if options.branch.startswith('wip/'):
|
||||
if os.path.exists(git_project_path):
|
||||
shutil.rmtree(git_project_path)
|
||||
|
@ -415,15 +429,19 @@ def setup_git_tree(project_name, options):
|
|||
except subprocess.CalledProcessError as e:
|
||||
print(e, file=sys.stderr)
|
||||
shutil.rmtree(git_project_path)
|
||||
return setup_git_tree(project_name, options)
|
||||
return setup_git_tree(project_reference, options)
|
||||
else:
|
||||
existing_tree = False
|
||||
os.chdir(settings.GIT_PATH)
|
||||
if project_name.startswith('/'):
|
||||
call("git clone %s" % project_name)
|
||||
if project_reference.startswith('/'):
|
||||
call("git clone %s" % project_reference)
|
||||
else:
|
||||
call("git clone %s/%s.git" % \
|
||||
(settings.GIT_REPOSITORY_URL, project_name))
|
||||
parsed = urllib.parse.urlparse(project_reference)
|
||||
if not parsed.netloc:
|
||||
project_url = urllib.parse.urljoin(settings.GIT_REPOSITORY_URL, project_name) + '.git'
|
||||
else:
|
||||
project_url = project_reference
|
||||
call("git clone %s" % project_url)
|
||||
|
||||
os.chdir(git_project_path)
|
||||
try:
|
||||
|
@ -435,7 +453,7 @@ def setup_git_tree(project_name, options):
|
|||
if existing_tree:
|
||||
print(e, file=sys.stderr)
|
||||
shutil.rmtree(git_project_path)
|
||||
return setup_git_tree(project_name, options)
|
||||
return setup_git_tree(project_reference, options)
|
||||
raise
|
||||
|
||||
|
||||
|
@ -448,8 +466,8 @@ def main():
|
|||
sys.exit(0)
|
||||
|
||||
init()
|
||||
project_name = args[0]
|
||||
git_project_path = os.path.join(settings.GIT_PATH, os.path.basename(project_name))
|
||||
project_reference = args[0]
|
||||
git_project_path = get_git_project_path(project_reference)
|
||||
atexit.register(clean_git_on_exit, git_project_path)
|
||||
if options.branch.startswith('origin/'):
|
||||
# normalize without origin/
|
||||
|
@ -465,7 +483,7 @@ def main():
|
|||
last_tag = "0.0"
|
||||
else:
|
||||
last_tag = "0.0"
|
||||
setup_git_tree(project_name, options)
|
||||
setup_git_tree(project_reference, options)
|
||||
project = get_project_infos(git_project_path, options)
|
||||
|
||||
if not os.path.exists(project['lock_path']):
|
||||
|
|
Loading…
Reference in New Issue