Created
October 29, 2025 20:17
-
-
Save bensheldon/bda0d1d6afc0dba3d389b0c1aee8e324 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% require_relative File.expand_path("git_worktree", __dir__) %> | |
| default: &default | |
| adapter: postgresql | |
| encoding: unicode | |
| pool: 20 | |
| connect_timeout: 5 | |
| checkout_timeout: 5 | |
| development: | |
| <<: *default | |
| database: frontdoor_development<%= GitWorktree.db_suffix %> | |
| test: | |
| <<: *default | |
| database: frontdoor_test<%= GitWorktree.db_suffix %><%= ENV["TEST_ENV_NUMBER"] %> | |
| demo: | |
| <<: *default | |
| database: frontdoor_demo | |
| production: | |
| <<: *default | |
| database: frontdoor_production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| # Helper for Git worktree-aware behavior | |
| module GitWorktree | |
| PROJECT_ROOT = File.expand_path("..", __dir__) | |
| def self.name | |
| git_path = File.join(PROJECT_ROOT, ".git") | |
| git_dir = nil | |
| if File.file?(git_path) | |
| contents = File.read(git_path, 1024) | |
| if contents && contents =~ /\Agitdir:\s*(.+)\s*\z/ | |
| git_dir = Regexp.last_match(1).strip | |
| end | |
| elsif File.directory?(git_path) | |
| git_dir = git_path | |
| end | |
| return nil unless git_dir&.include?("/worktrees/") | |
| raw = git_dir.split("/worktrees/").last.split("/").first | |
| sanitized = raw.to_s.gsub(/[^a-zA-Z0-9_]/, "_").downcase | |
| sanitized.empty? ? nil : sanitized | |
| end | |
| def self.db_suffix | |
| worktree = name | |
| worktree ? "_#{worktree}" : "" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment