Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update-checkout]: Add --fetch option. #25566

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions utils/update_checkout/update_checkout/update_checkout.py
Expand Up @@ -84,7 +84,7 @@ def get_branch_for_repo(config, repo_name, scheme_name, scheme_map,

def update_single_repository(args):
config, repo_name, scheme_name, scheme_map, tag, timestamp, \
reset_to_remote, should_clean, cross_repos_pr = args
reset_to_remote, should_clean, cross_repos_pr, should_fetch = args
repo_path = os.path.join(SWIFT_SOURCE_ROOT, repo_name)
if not os.path.isdir(repo_path):
return
Expand All @@ -94,6 +94,10 @@ def update_single_repository(args):
with shell.pushd(repo_path, dry_run=False, echo=False):
cross_repo = False
checkout_target = None

if should_fetch:
shell.run(['git', 'fetch'], echo=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some extra arguments are necessary:

Suggested change
shell.run(['git', 'fetch'], echo=True)
shell.run(['git', 'fetch'], echo=True)
shell.run(["git", "fetch", "--recurse-submodules=yes", "--tags"],
echo=True)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this exact git fetch command is executed a few lines later in the file:

            if checkout_target:
                shell.run(['git', 'status', '--porcelain', '-uno'],
                          echo=False)
                shell.run(['git', 'checkout', checkout_target], echo=True)

            # It's important that we checkout, fetch, and rebase, in order.
            # .git/FETCH_HEAD updates the not-for-merge attributes based on
            # which branch was checked out during the fetch.
            shell.run(["git", "fetch", "--recurse-submodules=yes", "--tags"],
                      echo=True)

But maybe it's being run too late?


if tag:
checkout_target = confirm_tag_in_repo(tag, repo_name)
elif scheme_name:
Expand Down Expand Up @@ -207,7 +211,8 @@ def update_all_repositories(args, config, scheme_name, cross_repos_pr):
timestamp,
args.reset_to_remote,
args.clean,
cross_repos_pr]
cross_repos_pr,
args.fetch]
pool_args.append(my_args)

return shell.run_parallel(update_single_repository, pool_args,
Expand Down Expand Up @@ -431,6 +436,10 @@ def main():
"--clone-with-ssh",
help="Obtain Sources for Swift and Related Projects via SSH",
action="store_true")
parser.add_argument(
"--fetch",
help="Fetch the latest branches and tags before checking out code.",
action="store_true")
parser.add_argument(
"--skip-history",
help="Skip histories when obtaining sources",
Expand Down