codekingpro/portable-devtools
114k
1# Copyright 2023-present, the HuggingFace Inc. team.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14"""Legacy `hf repo-files` command.15 16Kept for backward compatibility. Users are nudged to use `hf repos delete-files` instead.17"""18 19from typing import Annotated20 21import typer22 23from ._cli_utils import (24 RepoIdArg,25 RepoType,26 RepoTypeOpt,27 RevisionOpt,28 TokenOpt,29 get_hf_api,30 typer_factory,31)32from ._output import out33 34 35repo_files_cli = typer_factory(36 help="(Deprecated) Manage files in a repo on the Hub. Use `hf repos delete-files` instead."37)38 39 40@repo_files_cli.command(41 "delete",42)43def repo_files_delete(44 repo_id: RepoIdArg,45 patterns: Annotated[46 list[str],47 typer.Argument(48 help="Glob patterns to match files to delete. Based on fnmatch, '*' matches files recursively.",49 ),50 ],51 repo_type: RepoTypeOpt = RepoType.model,52 revision: RevisionOpt = None,53 commit_message: Annotated[54 str | None,55 typer.Option(56 help="The summary / title / first line of the generated commit.",57 ),58 ] = None,59 commit_description: Annotated[60 str | None,61 typer.Option(62 help="The description of the generated commit.",63 ),64 ] = None,65 create_pr: Annotated[66 bool,67 typer.Option(68 help="Whether to create a new Pull Request for these changes.",69 ),70 ] = False,71 token: TokenOpt = None,72) -> None:73 out.warning("`hf repo-files delete` is deprecated. Use `hf repos delete-files` instead.")74 api = get_hf_api(token=token)75 url = api.delete_files(76 delete_patterns=patterns,77 repo_id=repo_id,78 repo_type=repo_type.value,79 revision=revision,80 commit_message=commit_message,81 commit_description=commit_description,82 create_pr=create_pr,83 )84 out.result("Files deleted", repo_id=repo_id, commit_url=url)85 