Skip to content

Commit

Permalink
chore: remove unused CLIs (#2677)
Browse files Browse the repository at this point in the history
In this PR:
- Remove CLI in `generate_repo.py` and `generate_pr_description.py`
since these CLIs are migrated to `entry_point.py`.
  • Loading branch information
JoeWang1127 authored May 9, 2024
1 parent 7f96074 commit ea80d1c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 120 deletions.
1 change: 0 additions & 1 deletion library_generation/cli/generate_monorepo_gapic_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import click as click

from library_generation.utils.pom_generator import generate_gapic_bom
from library_generation.utils.pom_generator import generate_root_pom


@click.group(invoke_without_command=False)
Expand Down
49 changes: 1 addition & 48 deletions library_generation/generate_pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,14 @@
import calendar
import os
import shutil
import click as click
from typing import Dict
from git import Commit, Repo
from library_generation.model.generation_config import GenerationConfig, from_yaml
from library_generation.model.generation_config import GenerationConfig
from library_generation.utils.proto_path_utils import find_versioned_proto_path
from library_generation.utils.commit_message_formatter import format_commit_message
from library_generation.utils.commit_message_formatter import wrap_override_commit


@click.group(invoke_without_command=False)
@click.pass_context
@click.version_option(message="%(version)s")
def main(ctx):
pass


@main.command()
@click.option(
"--generation-config-yaml",
required=True,
type=str,
help="""
Path to generation_config.yaml that contains the metadata about
library generation.
The googleapis commit in the configuration is the latest commit,
inclusively, from which the commit message is considered.
""",
)
@click.option(
"--baseline-commit",
required=True,
type=str,
help="""
The baseline (oldest) commit, exclusively, from which the commit message is
considered.
This commit should be an ancestor of googleapis commit in configuration.
""",
)
def generate(
generation_config_yaml: str,
baseline_commit: str,
) -> None:
idx = generation_config_yaml.rfind("/")
config_path = generation_config_yaml[:idx]
generate_pr_descriptions(
config=from_yaml(generation_config_yaml),
baseline_commit=baseline_commit,
description_path=config_path,
)


def generate_pr_descriptions(
config: GenerationConfig,
baseline_commit: str,
Expand Down Expand Up @@ -218,7 +175,3 @@ def __get_commit_timestamp(commit: Commit) -> int:
:return: the timestamp of the commit
"""
return calendar.timegm(commit.committed_datetime.utctimetuple())


if __name__ == "__main__":
main()
72 changes: 1 addition & 71 deletions library_generation/generate_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import click as click
import library_generation.utils.utilities as util
from library_generation.generate_composed_library import generate_composed_library
from library_generation.model.generation_config import GenerationConfig, from_yaml
from library_generation.model.generation_config import GenerationConfig
from library_generation.model.library_config import LibraryConfig
from library_generation.utils.monorepo_postprocessor import monorepo_postprocessing


@click.group(invoke_without_command=False)
@click.pass_context
@click.version_option(message="%(version)s")
def main(ctx):
pass


@main.command()
@click.option(
"--generation-config-yaml",
required=True,
type=str,
help="""
Path to generation_config.yaml that contains the metadata about
library generation
""",
)
@click.option(
"--target-library-names",
required=False,
default=None,
type=str,
help="""
A list of libraries will be generated.
If specified, only the `library` whose library_name is in
target-library-names will be generated.
If not specified, all libraries in the configuration yaml will be generated.
The input string will be parsed to a list of string with comma as the
separator.
For example, apigeeconnect,alloydb-connectors will be parsed as a
list of two strings, apigeeconnect and alloydb-connectors.
""",
)
@click.option(
"--repository-path",
required=False,
default=".",
type=str,
help="""
If specified, the generated files will be sent to this location.
If not specified, the repository will be generated to the current working
directory.
""",
)
def generate(
generation_config_yaml: str,
target_library_names: str,
repository_path: str,
):
config = from_yaml(generation_config_yaml)
generate_from_yaml(
config_path=generation_config_yaml,
config=config,
repository_path=repository_path,
target_library_names=(
target_library_names.split(",")
if target_library_names is not None
else target_library_names
),
)


def generate_from_yaml(
config_path: str,
config: GenerationConfig,
Expand Down Expand Up @@ -152,7 +86,3 @@ def get_target_libraries(
for library in config.libraries
if library.get_library_name() in target_libraries
]


if __name__ == "__main__":
main()

0 comments on commit ea80d1c

Please sign in to comment.