Last active
February 21, 2026 22:11
-
-
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"].then { it.present? ? "_#{it}" : "" } %> | |
| 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 | |
| module GitWorktree | |
| def self.name | |
| git_dir = `git rev-parse --git-dir 2>/dev/null`.strip | |
| return nil if git_dir.empty? || git_dir.exclude?("/worktrees/") | |
| branch = `git rev-parse --abbrev-ref HEAD 2>/dev/null`.strip | |
| return nil if branch.empty? || branch == "HEAD" | |
| sanitized = branch.gsub(/[^a-zA-Z0-9_]/, "_").squeeze("_").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