Some more work on the new dependency resolution system.
This commit is contained in:
@@ -7,7 +7,7 @@ from SCons.Script import *
|
||||
|
||||
Import('env')
|
||||
|
||||
def _gitbranch(env: Environment, repo_name: str, remote_url: str, git_ref: str = "main") -> dict:
|
||||
def _clone(env: Environment, repo_name: str, remote_url: str):
|
||||
repo_dir = os.path.join(env['CLONE_DIR'], 'git', repo_name, '_bare')
|
||||
try:
|
||||
repo = Repo(repo_dir)
|
||||
@@ -16,6 +16,10 @@ def _gitbranch(env: Environment, repo_name: str, remote_url: str, git_ref: str =
|
||||
print(f'Initializing git repository at {repo_dir}.')
|
||||
repo = Repo.init(repo_dir, bare=True)
|
||||
origin = repo.create_remote('origin', remote_url)
|
||||
return repo, origin
|
||||
|
||||
def _gitbranch(env: Environment, repo_name: str, remote_url: str, git_ref: str = 'main') -> dict:
|
||||
repo, origin = _clone(env, repo_name, remote_url)
|
||||
worktree_dir = os.path.join(env['CLONE_DIR'], 'git', repo_name, hashlib.shake_128(git_ref.encode('utf-8')).hexdigest(6)) # TODO: commit hash would be better, right? -> not if it's a branch!
|
||||
if not os.path.exists(worktree_dir):
|
||||
print(f'Checking out into {worktree_dir}.')
|
||||
@@ -34,6 +38,12 @@ def _gitbranch(env: Environment, repo_name: str, remote_url: str, git_ref: str =
|
||||
'checkout_root': worktree_dir
|
||||
}
|
||||
|
||||
def _gittags(env: Environment, repo_name: str, remote_url: str, force_fetch: bool = False) -> 'list[str]':
|
||||
repo, origin = _clone(env, repo_name, remote_url)
|
||||
if force_fetch or env['UPDATE_REPOSITORIES']:
|
||||
origin.fetch(tags=True)
|
||||
return [t.name for t in repo.tags]
|
||||
|
||||
env.AddMethod(_gitbranch, 'GitBranch')
|
||||
env.AddMethod(_gittags, 'GitTags')
|
||||
Return('env')
|
||||
Reference in New Issue
Block a user