From 1d41b6fb506a3257ecea41d4f192cf518d10192c Mon Sep 17 00:00:00 2001 From: Ashley E Desimone Date: Thu, 16 Mar 2023 22:32:27 -0700 Subject: [PATCH] EdkRepo: Add --tags flag to sync command Add support for fetching tags. Additionally move messages indicating that the sync is starting for a repo to the begining of that process to improve messaging. Fixes #134 Signed-off-by: Ashley E Desimone --- edkrepo/commands/sync_command.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/edkrepo/commands/sync_command.py b/edkrepo/commands/sync_command.py index 511ba1f..02b1c36 100644 --- a/edkrepo/commands/sync_command.py +++ b/edkrepo/commands/sync_command.py @@ -76,6 +76,10 @@ def get_metadata(self): 'positional' : False, 'required' : False, 'help-text' : arguments.OVERRIDE_HELP}) + args.append({'name' : 'tags', + 'short-name' : 't', + 'required' : False, + 'help-text': sync_arguments.TAG_HELP}) args.append(SubmoduleSkipArgument) args.append(SourceManifestRepoArgument) return metadata @@ -167,6 +171,11 @@ def run_command(self, args, config): manifest_repo = manifest.general_config.source_manifest_repo global_manifest_path = get_manifest_repo_path(manifest_repo, config) for repo_to_sync in repo_sources_to_sync: + if not args.fetch: + ui_functions.print_info_msg(humble.SYNCING.format(repo_to_sync.root, repo.active_branch), header = False) + else: + ui_functions.print_info_msg(humble.FETCHING.format(repo_to_sync.root, repo.active_branch), header = False) + local_repo_path = os.path.join(workspace_path, repo_to_sync.root) # Update any hooks if global_manifest_directory is not None: @@ -174,6 +183,8 @@ def run_command(self, args, config): repo = Repo(local_repo_path) #Fetch notes repo.remotes.origin.fetch("refs/notes/*:refs/notes/*") + if args.tags: + repo.git.execute(['git', 'fetch', '--tags']) if repo_to_sync.patch_set: patchset_branch_creation_flow(repo_to_sync, repo, workspace_path, manifest, global_manifest_path, args.override) elif repo_to_sync.commit is None and repo_to_sync.tag is None: @@ -182,10 +193,7 @@ def run_command(self, args, config): repo.remotes.origin.fetch("refs/heads/{0}:refs/remotes/origin/{0}".format(repo_to_sync.branch)) #The new branch may not exist in the heads list yet if it is a new branch repo.git.checkout(repo_to_sync.branch) - if not args.fetch: - ui_functions.print_info_msg(humble.SYNCING.format(repo_to_sync.root, repo.active_branch), header = False) - else: - ui_functions.print_info_msg(humble.FETCHING.format(repo_to_sync.root, repo.active_branch), header = False) + try: repo.remotes.origin.fetch() except GitCommandError as e: