diff --git a/git_river/cli.py b/git_river/cli.py index 13439cb..29b7581 100644 --- a/git_river/cli.py +++ b/git_river/cli.py @@ -41,7 +41,7 @@ def main(ctx: click.Context) -> None: main.add_command(git_river.commands.clone.main) main.add_command(git_river.commands.config.main) main.add_command(git_river.commands.forge.main) -main.add_command(git_river.commands.repo.fetch_remotes) +main.add_command(git_river.commands.repo.update_remotes) main.add_command(git_river.commands.repo.merge_feature_branches) main.add_command(git_river.commands.repo.tidy_branches) main.add_command(git_river.commands.repo.rebase) diff --git a/git_river/commands/forge.py b/git_river/commands/forge.py index d408866..7ae54f0 100644 --- a/git_river/commands/forge.py +++ b/git_river/commands/forge.py @@ -207,9 +207,9 @@ def configure_remotes(workspace: RepositoryManager) -> None: repo.configure_remotes() -@main.command(name="fetch") +@main.command(name="update") @click.pass_obj -def fetch_remotes(workspace: RepositoryManager) -> None: +def update_remotes(workspace: RepositoryManager) -> None: """Fetch configured remotes for each repository.""" with git_river.ext.click.progressbar( iterable=workspace.existing(), @@ -218,7 +218,7 @@ def fetch_remotes(workspace: RepositoryManager) -> None: logger_name=__name__, ) as progress: for repo in progress: - repo.fetch_remotes() + repo.update_remotes() @main.command(name="tidy") diff --git a/git_river/commands/repo.py b/git_river/commands/repo.py index 16a1d65..2587161 100644 --- a/git_river/commands/repo.py +++ b/git_river/commands/repo.py @@ -89,11 +89,11 @@ ) -@click.command(name="fetch") +@click.command(name="update") @click_repo_option -def fetch_remotes(path: pathlib.Path) -> None: - """Fetch all remotes.""" - git_river.repository.LocalRepository.from_path(path).fetch_remotes() +def update_remotes(path: pathlib.Path) -> None: + """Update and prune all remotes.""" + git_river.repository.LocalRepository.from_path(path).update_remotes() @click.command(name="merge") @@ -141,7 +141,7 @@ def tidy_branches(path: pathlib.Path, dry_run: bool, mainline: typing.Optional[s mainline = repo.discover_mainline_branch(mainline) - repo.fetch_remotes(prune=True) + repo.update_remotes() repo.remove_merged_branches(mainline, dry_run=dry_run) @@ -195,7 +195,7 @@ def end( repo.fetch_branch_from_remote(mainline, remote=upstream) repo.switch_to_branch(mainline) repo.remove_merged_branches(mainline, dry_run=False) - repo.fetch_remotes(prune=True) + repo.update_remotes() if downstream := repo.discover_optional_downstream_remote(downstream): repo.push_to_remote(mainline, remote=downstream) diff --git a/git_river/repository.py b/git_river/repository.py index 95520bb..def8474 100644 --- a/git_river/repository.py +++ b/git_river/repository.py @@ -223,12 +223,11 @@ def create_remote(self, name: str, url: str) -> None: log.warning("Updating remote", remote=name, new={url}, old=set(remote.urls)) remote.set_url(url) - def fetch_remotes(self, prune: bool = True) -> None: + def update_remotes(self, prune: bool = True) -> None: + """Update (and prune) all remotes using 'git remote update'.""" log = self.bind(logger) - log.info("Fetching remotes") - for remote in self.repo.remotes: - log.debug("Fetching remote", remote=remote.name) - remote.fetch(prune=prune, tags=True) + log.info("Updating remotes") + self.repo.git._call_process("remote", "update", insert_kwargs_after="update", prune=prune) def remove_merged_branches(self, target: str, *, dry_run: bool = True) -> None: """Remove branches that have been merged into the repo's default branch.""" diff --git a/pyproject.toml b/pyproject.toml index 49134e2..f486064 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "git-river" -version = "1.3.1" +version = "1.4.0" readme = "README.md" description = "Tools for working with upstream repositories" homepage = "https://pypi.org/project/git-river/"