Skip to content

Commit

Permalink
move_check
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenyuLInx committed Oct 9, 2023
1 parent 0ebb1ac commit 22f917d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 14 additions & 1 deletion core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,20 @@ def deps(ctx, **kwargs):
There is a way to add new packages by providing an `--add-package` flag to deps command
which will allow user to specify a package they want to add in the format of packagename@version.
"""
task = DepsTask(ctx.obj["flags"], ctx.obj["project"])
flags = ctx.obj["flags"]
if flags.ADD_PACKAGE:
if not flags.ADD_PACKAGE["version"] and flags.SOURCE != "local":
raise BadOptionUsage(
message=f"Version is required in --add-package when a package when source is {flags.SOURCE}",
option_name="--add-package",
)
else:
if flags.DRY_RUN:
raise BadOptionUsage(
message="Invalid flag `--dry-run` when not using `--add-package`.",
option_name="--dry-run",
)
task = DepsTask(flags, ctx.obj["project"])
results = task.run()
success = task.interpret_results(results)
return results, success
Expand Down
10 changes: 0 additions & 10 deletions core/dbt/task/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,6 @@ def add(self):
yaml.safe_dump({"packages": []}, package_yml)
fire_event(Formatting("Created packages.yml"))

if not self.args.add_package["version"] and self.args.source != "local":
raise dbt.exceptions.DbtRuntimeError(
f"Version is required in --add-package when a package when source is {self.args.source}"
)

new_package_entry = _create_packages_yml_entry(
self.args.add_package["name"], self.args.add_package["version"], self.args.source
)
Expand Down Expand Up @@ -213,11 +208,6 @@ def lock(self) -> None:
def run(self) -> None:
if self.args.add_package:
self.add()
else:
if self.args.dry_run:
raise dbt.exceptions.DbtRuntimeError(
"Invalid flag `--dry-run` when not using `--add-package`."
)

# Check lock file exist and generated by the same pacakges.yml
# or dependencies.yml.
Expand Down

0 comments on commit 22f917d

Please sign in to comment.