From 3321f08c351ff1e819fa564011706bee919d6e6a Mon Sep 17 00:00:00 2001 From: Chaojie Date: Mon, 27 Nov 2023 12:13:22 +0800 Subject: [PATCH] Publisher support google artifacts repository (#836) * Publisher support google artifacts repository * add release note --------- Co-authored-by: Ofek Lev --- docs/history/hatch.md | 1 + src/hatch/publish/index.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/history/hatch.md b/docs/history/hatch.md index c2461b667..bcbe31615 100644 --- a/docs/history/hatch.md +++ b/docs/history/hatch.md @@ -34,6 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fix nushell activation - Better handling of flat storage directory hierarchies for the `virtual` environment type - Display useful information when running the `version` command outside of a project rather than erroring +- Properly support Google Artifact Registry ## [1.7.0](https://github.com/pypa/hatch/releases/tag/hatch-v1.7.0) - 2023-04-03 ## {: #hatch-v1.7.0 } diff --git a/src/hatch/publish/index.py b/src/hatch/publish/index.py index 98eedda56..380388ce8 100644 --- a/src/hatch/publish/index.py +++ b/src/hatch/publish/index.py @@ -75,10 +75,15 @@ def publish(self, artifacts: list, options: dict): if not user: user = cached_user_file.get_user(repo) if user is None: - if options['no_prompt']: - self.app.abort('Missing required option: user') - else: - user = updated_user = self.app.prompt('Enter your username', default='__TOKEN__') + import keyring + + creds = keyring.get_credential(repo, None) + user = creds and creds.username + if user is None: + if options['no_prompt']: + self.app.abort('Missing required option: user') + else: + user = updated_user = self.app.prompt('Enter your username', default='__TOKEN__') index.user = user updated_auth = None