|
16 | 16 | import sys |
17 | 17 | import traceback |
18 | 18 | from multiprocessing import freeze_support |
19 | | -from typing import Any, Dict, Hashable, Optional, Set, List, Tuple, Union |
| 19 | +from typing import Any, Dict, Hashable, Optional, List, Tuple, Union |
20 | 20 |
|
21 | 21 | from .cli_arguments import CliArguments |
22 | | -from .git_command import Git, GitException |
| 22 | +from .git_command import Git, GitException, is_any_repository_locked |
23 | 23 | from .runner_arguments import AdditionalSwiftSourcesArguments, UpdateArguments |
24 | 24 | from .parallel_runner import ParallelRunner |
| 25 | +from .commands import status |
25 | 26 |
|
26 | 27 |
|
27 | 28 | SCRIPT_FILE = Path(__file__).absolute() |
@@ -351,32 +352,6 @@ def get_scheme_map( |
351 | 352 | return None |
352 | 353 |
|
353 | 354 |
|
354 | | -def _is_any_repository_locked(pool_args: List[UpdateArguments]) -> Set[str]: |
355 | | - """Returns the set of locked repositories. |
356 | | -
|
357 | | - A repository is considered to be locked if its .git directory contains a |
358 | | - file ending in ".lock". |
359 | | -
|
360 | | - Args: |
361 | | - pool_args (List[Any]): List of arguments passed to the |
362 | | - `update_single_repository` function. |
363 | | -
|
364 | | - Returns: |
365 | | - Set[str]: The names of the locked repositories if any. |
366 | | - """ |
367 | | - |
368 | | - repos = [(x.source_root, x.repo_name) for x in pool_args] |
369 | | - locked_repositories = set() |
370 | | - for source_root, repo_name in repos: |
371 | | - dot_git_path = source_root.joinpath(repo_name, ".git") |
372 | | - if not dot_git_path.exists() or not dot_git_path.is_dir(): |
373 | | - continue |
374 | | - for file in dot_git_path.iterdir(): |
375 | | - if file.suffix == ".lock": |
376 | | - locked_repositories.add(repo_name) |
377 | | - return locked_repositories |
378 | | - |
379 | | - |
380 | 355 | def _move_llvm_project_to_first_index( |
381 | 356 | pool_args: Union[List[UpdateArguments], List[AdditionalSwiftSourcesArguments]], |
382 | 357 | ): |
@@ -438,7 +413,7 @@ def update_all_repositories( |
438 | 413 | ) |
439 | 414 | pool_args.append(my_args) |
440 | 415 |
|
441 | | - locked_repositories: set[str] = _is_any_repository_locked(pool_args) |
| 416 | + locked_repositories = is_any_repository_locked(pool_args) |
442 | 417 | if len(locked_repositories) > 0: |
443 | 418 | return skipped_repositories, [ |
444 | 419 | Exception(f"'{repo_name}' is locked by git. Cannot update it.") |
@@ -585,6 +560,7 @@ def obtain_all_additional_swift_sources( |
585 | 560 |
|
586 | 561 | new_args = AdditionalSwiftSourcesArguments( |
587 | 562 | args=args, |
| 563 | + source_root=args.source_root, |
588 | 564 | repo_name=repo_name, |
589 | 565 | repo_info=repo_info, |
590 | 566 | repo_branch=repo_branch, |
@@ -771,6 +747,9 @@ def main() -> int: |
771 | 747 | freeze_support() |
772 | 748 | args = CliArguments.parse_args() |
773 | 749 |
|
| 750 | + if args.command == "status": |
| 751 | + return status.run_status(args) |
| 752 | + |
774 | 753 | if not args.scheme: |
775 | 754 | if args.reset_to_remote: |
776 | 755 | print( |
|
0 commit comments