Repository: dbt-labs/dbt-core

Issue:
git package: warn if specified revision master, main
Follow up from #3057, #3104

Previously, if a git package was unpinned, dbt tried to install it from `master` (hard coded). In #3104, this was fixed to used `HEAD` (default branch, regardless of name) and continue to warn if unpinned.

We'd like to warn as well if the user specifies the package `revision` as `'master'` or `'main'`, since either almost certainly represents the default branch. Users can disable the warning with `warn-unpinned: false`.

### Example

```yml
packages:
  - git: https://github.com/fishtown-analytics/dbt-codegen 
    revision: master
  - git: https://github.com/tailsdotcom/dbt_artifacts   
    revision: main
  - git: https://gitlab.com/gitlab-data/snowflake_spend
  - package: fishtown-analytics/audit_helper
    version: 0.3.0
```

<details>
<summary> <code>$ dbt deps</code> </summary>

```
Running with dbt=0.19.0
WARNING: The git package "https://github.com/fishtown-analytics/dbt-codegen"
	is pinned to the "master" branch.
	This can introduce breaking changes into your project without warning!

See https://docs.getdbt.com/docs/package-management#section-specifying-package-versions
WARNING: The git package "https://github.com/tailsdotcom/dbt_artifacts"
	is pinned to the "main" branch.
	This can introduce breaking changes into your project without warning!

See https://docs.getdbt.com/docs/package-management#section-specifying-package-versions
WARNING: The git package "https://gitlab.com/gitlab-data/snowflake_spend"
	is not pinned, using HEAD (default branch).
	This can introduce breaking changes into your project without warning!

See https://docs.getdbt.com/docs/package-management#section-specifying-package-versions
WARNING: The git package "https://github.com/fishtown-analytics/dbt-codegen"
	is pinned to the "master" branch.
	This can introduce breaking changes into your project without warning!

See https://docs.getdbt.com/docs/package-management#section-specifying-package-versions
WARNING: The git package "https://github.com/tailsdotcom/dbt_artifacts"
	is pinned to the "main" branch.
	This can introduce breaking changes into your project without warning!

See https://docs.getdbt.com/docs/package-management#section-specifying-package-versions
WARNING: The git package "https://gitlab.com/gitlab-data/snowflake_spend"
	is not pinned, using HEAD (default branch).
	This can introduce breaking changes into your project without warning!

See https://docs.getdbt.com/docs/package-management#section-specifying-package-versions
Installing https://github.com/fishtown-analytics/dbt-codegen@master
  Installed from revision master

Installing https://github.com/tailsdotcom/dbt_artifacts@main
  Installed from revision main

Installing https://gitlab.com/gitlab-data/snowflake_spend@HEAD
  Installed from HEAD (default branch)

Installing fishtown-analytics/audit_helper@0.3.0
  Installed from version 0.3.0

Installing fishtown-analytics/dbt_utils@0.6.4
  Installed from version 0.6.4
```

</details>

```yml
packages:
  - git: https://github.com/fishtown-analytics/dbt-codegen 
    revision: master
    warn-unpinned: false
  - git: https://github.com/tailsdotcom/dbt_artifacts   
    revision: main
    warn-unpinned: false
  - git: https://gitlab.com/gitlab-data/snowflake_spend
    warn-unpinned: false
  - package: fishtown-analytics/audit_helper
    version: 0.3.0
```

<details>
<summary> <code>$ dbt deps</code> </summary>

```
Running with dbt=0.19.0
Installing https://github.com/fishtown-analytics/dbt-codegen@master
  Installed from revision master

Installing https://github.com/tailsdotcom/dbt_artifacts@main
  Installed from revision main

Installing https://gitlab.com/gitlab-data/snowflake_spend@HEAD
  Installed from HEAD (default branch)

Installing fishtown-analytics/audit_helper@0.3.0
  Installed from version 0.3.0

Installing fishtown-analytics/dbt_utils@0.6.4
  Installed from version 0.6.4
```
</details>

### Checklist
 - [x] I have signed the [CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
 - [x] I have run this code in development and it appears to resolve the stated issue
 - ~This PR includes tests, or tests are not required/relevant for this PR~
 - [x] I have updated the `CHANGELOG.md` and added information about my change to the "dbt next" section.



Discussion:
nice! I do think we should warn when using _any_ branch name to pin, but this is a step in that direction 👍 
> nice! I do think we should warn when using any branch name to pin, but this is a step in that direction 👍

@kwigley Do you mean, warn if users pin to a branch name in their `revision`, rather than a version number/release tag? That's fair! I don't think the git-based `deps` approach has a way today to differentiate between branch-name and release-name revisions.

Resolving patch:
diff --git a/core/dbt/clients/registry.py b/core/dbt/clients/registry.py
--- a/core/dbt/clients/registry.py
+++ b/core/dbt/clients/registry.py
@@ -28,11 +28,10 @@ def wrapper(*args, **kwargs):
             attempt += 1
             try:
                 return fn(*args, **kwargs)
-            except requests.exceptions.ConnectionError as exc:
+            except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as exc:
                 if attempt < max_attempts:
                     time.sleep(1)
                     continue
-
                 raise RegistryException(
                     'Unable to connect to registry hub'
                 ) from exc
@@ -43,7 +42,7 @@ def wrapper(*args, **kwargs):
 def _get(path, registry_base_url=None):
     url = _get_url(path, registry_base_url)
     logger.debug('Making package registry request: GET {}'.format(url))
-    resp = requests.get(url)
+    resp = requests.get(url, timeout=30)
     logger.debug('Response from registry: GET {} {}'.format(url,
                                                             resp.status_code))
     resp.raise_for_status()


Test patch:
diff --git a/test/unit/test_registry_get_request_exception.py b/test/unit/test_registry_get_request_exception.py
new file mode 100644
--- /dev/null
+++ b/test/unit/test_registry_get_request_exception.py
@@ -0,0 +1,9 @@
+import unittest
+
+from dbt.exceptions import RegistryException
+from dbt.clients.registry import _get
+
+class testRegistryGetRequestException(unittest.TestCase):
+    def test_registry_request_error_catching(self):
+        # using non routable IP to test connection error logic in the _get function
+        self.assertRaises(RegistryException, _get, '', 'http://10.255.255.1')