Skip to content

Commit

Permalink
Merge pull request #3117 from fishtown-analytics/fix/deps-git-warn-if…
Browse files Browse the repository at this point in the history
…-main-master

git package: warn if specified revision master, main
  • Loading branch information
jtcohen6 authored Feb 22, 2021
2 parents 49b8693 + c7c0574 commit be47a0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- Auto-generated CTEs in tests and ephemeral models have lowercase names to comply with dbt coding conventions ([#3027](https://github.com/fishtown-analytics/dbt/issues/3027), [#3028](https://github.com/fishtown-analytics/dbt/issues/3028))
- Fix incorrect error message when a selector does not match any node [#3036](https://github.com/fishtown-analytics/dbt/issues/3036))
- Fix variable `_dbt_max_partition` declaration and initialization for BigQuery incremental models ([#2940](https://github.com/fishtown-analytics/dbt/issues/2940), [#2976](https://github.com/fishtown-analytics/dbt/pull/2976))
- Moving from 'master' to 'HEAD' default branch in git ([#3057](https://github.com/fishtown-analytics/dbt/issues/3057))
- Moving from 'master' to 'HEAD' default branch in git ([#3057](https://github.com/fishtown-analytics/dbt/issues/3057), [#3104](https://github.com/fishtown-analytics/dbt/issues/3104), [#3117](https://github.com/fishtown-analytics/dbt/issues/3117)))

### Features
- Add optional configs for `require_partition_filter` and `partition_expiration_days` in BigQuery ([#1843](https://github.com/fishtown-analytics/dbt/issues/1843), [#2928](https://github.com/fishtown-analytics/dbt/pull/2928))
Expand Down
20 changes: 16 additions & 4 deletions core/dbt/deps/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ def get_version(self):
return self.revision

def nice_version_name(self):
return 'revision {}'.format(self.revision)
if self.revision == 'HEAD':
return 'HEAD (default branch)'
else:
return 'revision {}'.format(self.revision)

def unpinned_msg(self):
if self.revision == 'HEAD':
return 'not pinned, using HEAD (default branch)'
elif self.revision in ('main', 'master'):
return f'pinned to the "{self.revision}" branch'
else:
return None

def _checkout(self):
"""Performs a shallow clone of the repository into the downloads
Expand All @@ -72,11 +83,12 @@ def _checkout(self):

def _fetch_metadata(self, project, renderer) -> ProjectPackageMetadata:
path = self._checkout()
if self.revision == 'HEAD' and self.warn_unpinned:

if self.unpinned_msg() and self.warn_unpinned:
warn_or_error(
'The git package "{}" is not pinned.\n\tThis can introduce '
'The git package "{}" \n\tis {}.\n\tThis can introduce '
'breaking changes into your project without warning!\n\nSee {}'
.format(self.git, PIN_PACKAGE_URL),
.format(self.git, self.unpinned_msg(), PIN_PACKAGE_URL),
log_fmt=ui.yellow('WARNING: {}')
)
loaded = Project.from_project_root(path, renderer)
Expand Down

0 comments on commit be47a0c

Please sign in to comment.