|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Clean up legacy full-URL bundler credential keys. |
| 4 | +# |
| 5 | +# Older setups (or manual configuration) stored GitHub Packages credentials |
| 6 | +# using the full-URL format: |
| 7 | +# BUNDLE_HTTPS://RUBYGEMS__PKG__GITHUB__COM/TRUSTED/ |
| 8 | +# |
| 9 | +# setup.sh now uses the host-only format (rubygems.pkg.github.com), which is |
| 10 | +# broader in scope and matches Bundler's documented convention. Both formats |
| 11 | +# work, but having the legacy key lingering causes inconsistency across |
| 12 | +# machines and confuses doctor.sh checks. |
| 13 | +# |
| 14 | +# This migration removes legacy full-URL keys. The correct host-only keys |
| 15 | +# are set by registries_setup.sh, which runs before migrations. |
| 16 | + |
| 17 | +BUNDLE_CONFIG="$HOME/.bundle/config" |
| 18 | + |
| 19 | +if [ ! -f "$BUNDLE_CONFIG" ]; then |
| 20 | + echo " No ~/.bundle/config found — nothing to clean up." |
| 21 | + exit 0 |
| 22 | +fi |
| 23 | + |
| 24 | +# Remove legacy full-URL GitHub Packages credential |
| 25 | +if grep -q 'BUNDLE_HTTPS://RUBYGEMS__PKG__GITHUB__COM' "$BUNDLE_CONFIG" 2>/dev/null; then |
| 26 | + bundle config unset --global "https://rubygems.pkg.github.com/trusted/" > /dev/null 2>&1 |
| 27 | + echo " Removed legacy key: https://rubygems.pkg.github.com/trusted/" |
| 28 | +else |
| 29 | + echo " No legacy GitHub Packages key found — skipping." |
| 30 | +fi |
| 31 | + |
| 32 | +# Remove stray BUNDLE_GET entry (likely a misconfigured credential) |
| 33 | +if grep -q '^BUNDLE_GET:' "$BUNDLE_CONFIG" 2>/dev/null; then |
| 34 | + # bundle config doesn't support unsetting arbitrary keys cleanly, |
| 35 | + # so we remove the line directly. |
| 36 | + sed -i.bak '/^BUNDLE_GET:/d' "$BUNDLE_CONFIG" |
| 37 | + rm -f "${BUNDLE_CONFIG}.bak" |
| 38 | + echo " Removed stray BUNDLE_GET entry." |
| 39 | +else |
| 40 | + echo " No stray BUNDLE_GET entry — skipping." |
| 41 | +fi |
0 commit comments