|
7 | 7 | import yaml |
8 | 8 | from dbt.contracts.graph.manifest import Manifest, ManifestNode |
9 | 9 | from dbt.contracts.graph.parsed import ColumnInfo |
10 | | -from git import Repo |
11 | 10 |
|
12 | 11 | from ..cli_constants import BUILD_DIR |
13 | | -from ..cli_utils import echo_info |
| 12 | +from ..cli_utils import echo_info, echo_warning |
14 | 13 | from ..config_generation import read_dictionary_from_config_directory |
15 | 14 | from ..data_structures import DbtModel, DbtSource, DbtTableColumn |
16 | 15 | from ..errors import DataPipelinesError |
17 | 16 |
|
| 17 | +try: |
| 18 | + from git import Repo |
| 19 | + |
| 20 | + GIT_EXISTS = True |
| 21 | +except ImportError: |
| 22 | + echo_warning("Git support not installed.") |
| 23 | + GIT_EXISTS = False |
| 24 | + |
18 | 25 |
|
19 | 26 | def _get_project_name_and_version() -> Tuple[str, str]: |
20 | 27 | with open(pathlib.Path.cwd().joinpath("dbt_project.yml"), "r") as f: |
@@ -132,17 +139,18 @@ def _copy_publication_to_repo(package_dest: pathlib.Path, package_path: pathlib. |
132 | 139 | shutil.copytree(package_path, package_dest) |
133 | 140 |
|
134 | 141 |
|
135 | | -def _configure_git_env(repo: Repo, config: Dict[str, Any]) -> None: |
136 | | - repo.config_writer().set_value("user", "name", config["username"]).release() |
137 | | - repo.config_writer().set_value("user", "email", config["email"]).release() |
| 142 | +if GIT_EXISTS: |
138 | 143 |
|
| 144 | + def _configure_git_env(repo: Repo, config: Dict[str, Any]) -> None: |
| 145 | + repo.config_writer().set_value("user", "name", config["username"]).release() |
| 146 | + repo.config_writer().set_value("user", "email", config["email"]).release() |
139 | 147 |
|
140 | | -def _commit_and_push_changes(repo: Repo, project_name: str, project_version: str) -> None: |
141 | | - echo_info("Publishing") |
142 | | - repo.git.add(all=True) |
143 | | - repo.index.commit(f"Publication from project {project_name}, version: {project_version}") |
144 | | - origin = repo.remote(name="origin") |
145 | | - origin.push() |
| 148 | + def _commit_and_push_changes(repo: Repo, project_name: str, project_version: str) -> None: |
| 149 | + echo_info("Publishing") |
| 150 | + repo.git.add(all=True) |
| 151 | + repo.index.commit(f"Publication from project {project_name}, version: {project_version}") |
| 152 | + origin = repo.remote(name="origin") |
| 153 | + origin.push() |
146 | 154 |
|
147 | 155 |
|
148 | 156 | def publish_package(package_path: pathlib.Path, key_path: str, env: str) -> None: |
|
0 commit comments