diff --git a/core/dbt/deps/git.py b/core/dbt/deps/git.py index 4f8c3ba376f..ad9fc837cd2 100644 --- a/core/dbt/deps/git.py +++ b/core/dbt/deps/git.py @@ -101,11 +101,14 @@ def _fetch_metadata( self, project: Project, renderer: PackageRenderer ) -> ProjectPackageMetadata: path = self._checkout() - # overwrite 'revision' with actual commit SHA - self.revision = git.get_current_sha(path) + # raise warning (or error) if this package is not pinned if (self.revision == "HEAD" or self.revision in ("main", "master")) and self.warn_unpinned: - warn_or_error(DepsUnpinned(git=self.git)) + warn_or_error(DepsUnpinned(revision=self.revision, git=self.git)) + + # now overwrite 'revision' with actual commit SHA + self.revision = git.get_current_sha(path) + partial = PartialProject.from_project_root(path) return partial.render_package_metadata(renderer)