pkglistgen: Support working on git branches
Following scmsync syntax where a branch can be specified behind the URL fragment hash Co-authored-by: Fabian Vogt <fabian@ritter-vogt.de>
This commit is contained in:
parent
34947e2bfe
commit
feb1e3f03b
@ -696,17 +696,24 @@ class PkgListGen(ToolBase.ToolBase):
|
|||||||
logging.info(f'{project}/{product} build in progress')
|
logging.info(f'{project}/{product} build in progress')
|
||||||
return
|
return
|
||||||
if git_url:
|
if git_url:
|
||||||
|
git_url_base, *fragment = git_url.split('#')
|
||||||
if os.path.exists(cache_dir + "/.git"):
|
if os.path.exists(cache_dir + "/.git"):
|
||||||
# reset and update existing clone
|
# reset and update existing clone
|
||||||
logging.debug(subprocess.check_output(
|
logging.debug(subprocess.check_output(
|
||||||
['git', 'reset', '--hard'], cwd=cache_dir, encoding='utf-8'))
|
['git', 'reset', '--hard'], cwd=cache_dir, encoding='utf-8'))
|
||||||
logging.debug(subprocess.check_output(
|
logging.debug(subprocess.check_output(
|
||||||
['git', 'pull', '--rebase'], cwd=cache_dir, encoding='utf-8'))
|
['git', 'pull', '--rebase'], cwd=cache_dir, encoding='utf-8'))
|
||||||
|
if fragment:
|
||||||
|
# FIXME: this is not takeing account default branches, which may change server side
|
||||||
|
logging.debug(subprocess.check_output(
|
||||||
|
['git', 'switch', fragment[0]], cwd=cache_dir, encoding='utf-8'))
|
||||||
else:
|
else:
|
||||||
if os.path.exists(cache_dir):
|
if os.path.exists(cache_dir):
|
||||||
shutil.rmtree(cache_dir)
|
shutil.rmtree(cache_dir)
|
||||||
logging.debug(subprocess.check_output(
|
args = ['git', 'clone', '--recurse-submodules', git_url_base, cache_dir]
|
||||||
['git', 'clone', '--recurse-submodules', git_url, cache_dir], encoding='utf-8'))
|
if fragment:
|
||||||
|
args += ['--branch', fragment[0]]
|
||||||
|
logging.debug(subprocess.check_output(args, encoding='utf-8'))
|
||||||
if os.path.exists(cache_dir + '/' + '000update-repos'):
|
if os.path.exists(cache_dir + '/' + '000update-repos'):
|
||||||
logging.error('No support for 000update-repos in git projects atm')
|
logging.error('No support for 000update-repos in git projects atm')
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user