rails-worktree 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/worktree/commands/close.rb +17 -17
- data/lib/worktree/commands/init.rb +7 -19
- data/lib/worktree/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e7212fc3b6e29ec0889e74aa816833e5709c61ffe580138d793eb7e32774b9e
|
|
4
|
+
data.tar.gz: 40ffa81276288089b12c97655fda37718fc34ca3414ff475acb961afc073fd9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0c3ecb5d1e2ba749a205172ba8eb5cfe1fc85fcdf96daa7e55194b92f647fb21497c59e980cab8505854a9c4d034211513b5232a2319e53d4ba12b3f7f44ac2
|
|
7
|
+
data.tar.gz: 9d215b260bd60c01c3494d840f022b95ead4f86010632118f8290b738ab021a1c40f9588e550e60aa9a6aa05c2c991e57f7c3e16b99355f2541a0268c70ae49a
|
|
@@ -22,6 +22,9 @@ module RailsWorktree
|
|
|
22
22
|
puts "Main worktree: #{@main_worktree}"
|
|
23
23
|
puts ""
|
|
24
24
|
|
|
25
|
+
# Move to main worktree early so we're not inside the directory we're about to delete
|
|
26
|
+
Dir.chdir(@main_worktree) unless @in_main_repo
|
|
27
|
+
|
|
25
28
|
drop_databases
|
|
26
29
|
remove_node_modules
|
|
27
30
|
remove_worktree
|
|
@@ -34,6 +37,11 @@ module RailsWorktree
|
|
|
34
37
|
puts " node_modules removed"
|
|
35
38
|
puts " Worktree removed from #{@worktree_path}"
|
|
36
39
|
puts " Branch #{@worktree_name} deleted"
|
|
40
|
+
|
|
41
|
+
unless @in_main_repo
|
|
42
|
+
puts ""
|
|
43
|
+
puts "Run: cd #{@main_worktree}"
|
|
44
|
+
end
|
|
37
45
|
end
|
|
38
46
|
|
|
39
47
|
private
|
|
@@ -80,24 +88,19 @@ module RailsWorktree
|
|
|
80
88
|
end
|
|
81
89
|
end
|
|
82
90
|
|
|
83
|
-
def database_env
|
|
84
|
-
{
|
|
85
|
-
"DATABASE_NAME_DEVELOPMENT" => @dev_database_name,
|
|
86
|
-
"DATABASE_NAME_TEST" => @test_database_name
|
|
87
|
-
}
|
|
88
|
-
end
|
|
89
|
-
|
|
90
91
|
def drop_databases
|
|
91
92
|
puts "Dropping databases..."
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
if system("dropdb", "--if-exists", @dev_database_name)
|
|
95
|
+
puts "Dropped database '#{@dev_database_name}'"
|
|
96
|
+
else
|
|
97
|
+
puts "Warning: Could not drop development database #{@dev_database_name}"
|
|
98
|
+
end
|
|
97
99
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
if system("dropdb", "--if-exists", @test_database_name)
|
|
101
|
+
puts "Dropped database '#{@test_database_name}'"
|
|
102
|
+
else
|
|
103
|
+
puts "Warning: Could not drop test database #{@test_database_name}"
|
|
101
104
|
end
|
|
102
105
|
end
|
|
103
106
|
|
|
@@ -116,9 +119,6 @@ module RailsWorktree
|
|
|
116
119
|
def remove_worktree
|
|
117
120
|
puts "Removing worktree..."
|
|
118
121
|
|
|
119
|
-
# Change back to main repo if needed
|
|
120
|
-
Dir.chdir(@main_worktree) unless @in_main_repo
|
|
121
|
-
|
|
122
122
|
if system("git worktree remove #{@worktree_path} --force 2>/dev/null")
|
|
123
123
|
puts "Worktree removed successfully via git"
|
|
124
124
|
else
|
|
@@ -112,25 +112,13 @@ module RailsWorktree
|
|
|
112
112
|
|
|
113
113
|
content = File.read(database_yml)
|
|
114
114
|
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
content.gsub!(
|
|
121
|
-
|
|
122
|
-
"database: <%= ENV.fetch(\"DATABASE_NAME_DEVELOPMENT\", \"#{@db_prefix}_development\") %>"
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
# Update test database
|
|
126
|
-
content.gsub!(
|
|
127
|
-
/database:\s*<%= ENV\.fetch\("DATABASE_NAME",\s*"#{@db_prefix}_test"\s*%>/,
|
|
128
|
-
"database: <%= ENV.fetch(\"DATABASE_NAME_TEST\", \"#{@db_prefix}_test\") %>"
|
|
129
|
-
)
|
|
130
|
-
content.gsub!(
|
|
131
|
-
/database:\s*#{@db_prefix}_test/,
|
|
132
|
-
"database: <%= ENV.fetch(\"DATABASE_NAME_TEST\", \"#{@db_prefix}_test\") %>"
|
|
133
|
-
)
|
|
115
|
+
# Replace original database names with worktree-specific ones wherever they appear
|
|
116
|
+
# This handles hardcoded names, ERB defaults, env var defaults, etc.
|
|
117
|
+
original_dev = "#{@db_prefix}_development"
|
|
118
|
+
original_test = "#{@db_prefix}_test"
|
|
119
|
+
|
|
120
|
+
content.gsub!(original_dev, @dev_database_name)
|
|
121
|
+
content.gsub!(original_test, @test_database_name)
|
|
134
122
|
|
|
135
123
|
File.write(database_yml, content)
|
|
136
124
|
end
|
data/lib/worktree/version.rb
CHANGED