Skip to content

Commit

Permalink
Merge pull request #179 from dbt-labs/default-to-prerelease
Browse files Browse the repository at this point in the history
default prerelease to true
  • Loading branch information
dave-connors-3 authored Sep 25, 2023
2 parents 07ff2d2 + e88e6fa commit 056cd2b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
7 changes: 7 additions & 0 deletions dbt_meshify/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
help="Skips the dbt docs generate step and reads the local catalog.json file.",
)

latest = click.option(
"--latest",
"-l",
is_flag=True,
help="Makes the newest version the latest version when incrementing model versions",
)


def owner(func):
"""Add click options and argument validation for creating Owner objects."""
Expand Down
15 changes: 8 additions & 7 deletions dbt_meshify/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
exclude,
exclude_projects,
group_yml_path,
latest,
owner,
owner_email,
owner_name,
Expand Down Expand Up @@ -357,14 +358,14 @@ def add_version(
@read_catalog
@select
@selector
@click.option("--prerelease", "--pre", default=False, is_flag=True)
@latest
@click.option("--defined-in", default=None)
def bump_version(
select,
exclude,
project_path,
selector,
prerelease: bool,
latest: bool,
defined_in: Optional[Path],
read_catalog,
) -> List[ChangeSet]:
Expand Down Expand Up @@ -397,7 +398,7 @@ def bump_version(
continue

changes: ChangeSet = versioner.bump_version(
model=model_node, prerelease=prerelease, defined_in=defined_in
model=model_node, prerelease=not (latest), defined_in=defined_in
)
change_set.extend(changes)

Expand All @@ -413,14 +414,14 @@ def bump_version(
@read_catalog
@select
@selector
@click.option("--prerelease", "--pre", default=False, is_flag=True)
@latest
@click.option("--defined-in", default=None)
def version(
select,
exclude,
project_path,
selector,
prerelease: bool,
latest: bool,
defined_in: Optional[Path],
read_catalog,
) -> List[ChangeSet]:
Expand Down Expand Up @@ -459,7 +460,7 @@ def version(
versioner.bump_version(
model=model_node,
defined_in=defined_in,
prerelease=prerelease,
prerelease=not (latest),
)
)

Expand All @@ -483,7 +484,7 @@ def version(
bump_change: ChangeSet = versioner.bump_version(
model=model_node,
defined_in=defined_in,
prerelease=prerelease,
prerelease=not (latest),
model_override=model_add_change.data,
)

Expand Down
16 changes: 8 additions & 8 deletions tests/integration/test_version_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from ..sql_and_yml_fixtures import (
expected_versioned_model_yml_increment_prerelease_version,
expected_versioned_model_yml_increment_prerelease_version_with_second_prerelease,
expected_versioned_model_yml_increment_version_defined_in,
expected_versioned_model_yml_increment_version_no_prerelease,
expected_versioned_model_yml_increment_version_with_prerelease,
expected_versioned_model_yml_no_version,
expected_versioned_model_yml_no_yml,
expected_versioned_model_yml_prerelease_defined_in,
model_yml_increment_version,
model_yml_no_col_no_version,
model_yml_string_version,
Expand Down Expand Up @@ -109,7 +109,7 @@ def test_add_version_version_in_yml(
),
(
model_yml_increment_version,
expected_versioned_model_yml_increment_version_defined_in,
expected_versioned_model_yml_prerelease_defined_in,
["shared_model.sql"],
["shared_model_v1.sql", "daves_model.sql"],
["--defined-in", "daves_model"],
Expand Down Expand Up @@ -211,18 +211,18 @@ def test_bump_version_fails_when_no_versions_present(
expected_versioned_model_yml_increment_version_no_prerelease,
["shared_model.sql"],
["shared_model_v1.sql", "shared_model_v2.sql"],
[],
["--latest"],
),
(
model_yml_increment_version,
expected_versioned_model_yml_increment_version_with_prerelease,
["shared_model.sql"],
["shared_model_v1.sql", "shared_model_v2.sql"],
["--prerelease"],
[],
),
(
model_yml_increment_version,
expected_versioned_model_yml_increment_version_defined_in,
expected_versioned_model_yml_prerelease_defined_in,
["shared_model.sql"],
["shared_model_v1.sql", "daves_model.sql"],
["--defined-in", "daves_model"],
Expand All @@ -232,14 +232,14 @@ def test_bump_version_fails_when_no_versions_present(
expected_versioned_model_yml_increment_prerelease_version_with_second_prerelease,
["shared_model_v1.sql", "shared_model_v2.sql"],
["shared_model_v1.sql", "shared_model_v2.sql", "shared_model_v3.sql"],
["--prerelease"],
[],
),
(
expected_versioned_model_yml_increment_version_with_prerelease,
expected_versioned_model_yml_increment_prerelease_version,
["shared_model_v1.sql", "shared_model_v2.sql"],
["shared_model_v1.sql", "shared_model_v2.sql", "shared_model_v3.sql"],
[],
["--latest"],
),
],
ids=["1", "2", "3", "4", "5"],
Expand Down Expand Up @@ -289,7 +289,7 @@ def test_bump_version_in_yml(
model_yml_increment_version,
expected_versioned_model_yml_increment_version_with_prerelease,
["shared_model_v1.sql", "shared_model_v2.sql"],
["--prerelease"],
[],
)
],
)
Expand Down
4 changes: 2 additions & 2 deletions tests/sql_and_yml_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@
- v: 3
"""

expected_versioned_model_yml_increment_version_defined_in = """
expected_versioned_model_yml_prerelease_defined_in = """
models:
- name: shared_model
latest_version: 2
latest_version: 1
description: "this is a test model"
versions:
- v: 1
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_add_version_to_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

from ..dbt_project_fixtures import model, project # noqa: F401
from ..sql_and_yml_fixtures import (
expected_versioned_model_yml_increment_version_defined_in,
expected_versioned_model_yml_increment_version_no_prerelease,
expected_versioned_model_yml_increment_version_with_prerelease,
expected_versioned_model_yml_no_version,
expected_versioned_model_yml_no_yml,
expected_versioned_model_yml_prerelease_defined_in,
model_yml_increment_version,
model_yml_no_col_no_version,
)
Expand Down Expand Up @@ -81,9 +81,9 @@ def test_add_version_to_model_yml_increment_version_defined_in(
self, model, project, file_manager # noqa: F811
):
versioner = ModelVersioner(project=project, file_manager=file_manager)
changes = list(versioner.bump_version(model, defined_in="daves_model"))
changes = list(versioner.bump_version(model, defined_in="daves_model", prerelease=True))
yml_dict = ResourceFileEditor.update_resource(
properties=read_yml(model_yml_increment_version), change=changes[0]
)

assert yml_dict == read_yml(expected_versioned_model_yml_increment_version_defined_in)
assert yml_dict == read_yml(expected_versioned_model_yml_prerelease_defined_in)

0 comments on commit 056cd2b

Please sign in to comment.