Skip to content

Commit abd7b27

Browse files
committed
fix(install): fix silent error with better error message when git not
installed
1 parent d0a95eb commit abd7b27

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/esgvoc/core/service/state.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ def build_db(self, missing_links_tracker: Optional["MissingLinksTracker"] = None
166166
universe_create_db(Path(self.db_path))
167167
self.db_connection = DBConnection(db_file_path=Path(self.db_path))
168168

169+
if self.local_version is None:
170+
raise RuntimeError(
171+
f"Unable to determine git version for repository at {self.local_path}.\n"
172+
"Possible causes:\n"
173+
" - Git is not installed on this machine. Install git and try again.\n"
174+
" - The repository folder exists but is not a valid git repository.\n"
175+
f" Try removing it and reinstalling: rm -rf {self.local_path} && esgvoc install"
176+
)
169177
ingest_metadata_universe(self.db_connection, self.local_version)
170178
print("Filling Universe DB")
171179
if self.local_path:
@@ -175,6 +183,14 @@ def build_db(self, missing_links_tracker: Optional["MissingLinksTracker"] = None
175183
print("Building Project DB from ", self.local_path)
176184
project_create_db(Path(self.db_path))
177185
print("Filling project DB")
186+
if self.local_path and self.local_version is None:
187+
raise RuntimeError(
188+
f"Unable to determine git version for repository at {self.local_path}.\n"
189+
"Possible causes:\n"
190+
" - Git is not installed on this machine. Install git and try again.\n"
191+
" - The repository folder exists but is not a valid git repository.\n"
192+
f" Try removing it and reinstalling: rm -rf {self.local_path} && esgvoc install"
193+
)
178194
if self.local_path and self.local_version:
179195
ingest_project(Path(self.local_path), Path(self.db_path), self.local_version, missing_links_tracker)
180196
self.fetch_version_db()

0 commit comments

Comments
 (0)