code_healer 0.1.8 → 0.1.11
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/CHANGELOG.md +20 -0
- data/lib/code_healer/healing_workspace_manager.rb +88 -45
- data/lib/code_healer/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: 4be2602f991eaa2b9952ab40d9b582bb80482b7e1238dfa3b1019649d3a7c67a
|
4
|
+
data.tar.gz: c7762eeafe979d09f1620145f46357b822582770095a1ba7bb7be24645818715
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29e14dea885f980028dbe1105dd9d188ae547ecaba7a4e6e46332fe1c34af437bbf9351ca868fdbc7afb0d644e3d9a3c38ba38979d2206ca1eaa744a98bc451b
|
7
|
+
data.tar.gz: 7857192ea8f774737b3ed3093679a0cf46f8af3db7e10117aa414bce3e7163b64a247d4446b0fa835191cb58cb204fc405299082790f05bc7885d85fc96ed94b
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.1.11] - 2025-01-14
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- **Repository cloning** - Now clones from GitHub remote URL instead of local path
|
12
|
+
- **Git remote configuration** - Ensures workspace has correct GitHub remote for PR creation
|
13
|
+
- **Debug information** - Added Git remote and branch debugging in workspace operations
|
14
|
+
|
15
|
+
## [0.1.10] - 2025-01-14
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- **Complete workspace isolation** - All Git operations now happen in isolated workspace only
|
19
|
+
- **No file copying** - Removed file copying between workspace and main repo
|
20
|
+
- **Direct PR creation** - Pull requests are created directly from the isolated workspace
|
21
|
+
- **Main repo protection** - Main repository is never touched, only the isolated workspace
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- **Git commit workflow** - Added proper change detection before committing
|
25
|
+
- **Empty branch prevention** - Delete healing branches when no changes are detected
|
26
|
+
- **Enhanced debugging** - Added Git status and diff logging throughout the process
|
27
|
+
|
8
28
|
## [0.1.8] - 2025-01-14
|
9
29
|
|
10
30
|
### Changed
|
@@ -78,6 +78,14 @@ module CodeHealer
|
|
78
78
|
apply_fix_to_file(file_path, fix[:new_code], class_name, method_name)
|
79
79
|
end
|
80
80
|
|
81
|
+
# Show workspace Git status after applying fixes
|
82
|
+
Dir.chdir(workspace_path) do
|
83
|
+
puts "🔧 [WORKSPACE] Git status after fixes:"
|
84
|
+
system("git status --porcelain")
|
85
|
+
puts "🔧 [WORKSPACE] Git diff after fixes:"
|
86
|
+
system("git diff")
|
87
|
+
end
|
88
|
+
|
81
89
|
puts "✅ Fixes applied successfully in workspace"
|
82
90
|
true
|
83
91
|
rescue => e
|
@@ -121,51 +129,74 @@ module CodeHealer
|
|
121
129
|
end
|
122
130
|
|
123
131
|
def create_healing_branch(repo_path, workspace_path, branch_name)
|
124
|
-
puts "🔄 Creating healing branch
|
132
|
+
puts "🔄 Creating healing branch and PR from isolated workspace"
|
125
133
|
|
126
134
|
begin
|
127
|
-
#
|
128
|
-
Dir.chdir(
|
135
|
+
# All Git operations happen in the isolated workspace
|
136
|
+
Dir.chdir(workspace_path) do
|
137
|
+
puts "🌿 [WORKSPACE] Working in isolated workspace: #{workspace_path}"
|
138
|
+
|
139
|
+
# Debug Git configuration
|
140
|
+
puts "🌿 [WORKSPACE] Git remote origin: #{`git config --get remote.origin.url`.strip}"
|
141
|
+
puts "🌿 [WORKSPACE] Current branch: #{`git branch --show-current`.strip}"
|
142
|
+
|
129
143
|
# Ensure we're on the target branch
|
130
144
|
system("git checkout #{branch_name}")
|
131
145
|
system("git pull origin #{branch_name}")
|
132
146
|
|
133
|
-
# Create healing branch
|
147
|
+
# Create healing branch in the workspace
|
134
148
|
healing_branch = "code-healer-fix-#{Time.now.to_i}"
|
135
149
|
system("git checkout -b #{healing_branch}")
|
136
150
|
|
137
|
-
#
|
138
|
-
|
139
|
-
|
151
|
+
# Check Git status
|
152
|
+
puts "📊 [WORKSPACE] Git status in workspace:"
|
153
|
+
system("git status --porcelain")
|
140
154
|
|
141
|
-
#
|
155
|
+
# Add all changes (the fixes are already applied in the workspace)
|
142
156
|
system("git add .")
|
143
|
-
commit_message = "Fix applied by CodeHealer: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
|
144
|
-
system("git commit -m '#{commit_message}'")
|
145
|
-
|
146
|
-
# Push healing branch (this doesn't affect the main branch)
|
147
|
-
system("git push origin #{healing_branch}")
|
148
157
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
+
# Check if there are changes to commit
|
159
|
+
if system("git diff --cached --quiet") == false
|
160
|
+
puts "📝 [WORKSPACE] Changes detected, committing to healing branch..."
|
161
|
+
commit_message = "Fix applied by CodeHealer: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
|
162
|
+
system("git commit -m '#{commit_message}'")
|
163
|
+
|
164
|
+
# Push healing branch from workspace
|
165
|
+
puts "🚀 [WORKSPACE] Pushing healing branch from workspace..."
|
166
|
+
system("git push origin #{healing_branch}")
|
167
|
+
|
168
|
+
puts "✅ [WORKSPACE] Healing branch created and pushed: #{healing_branch}"
|
169
|
+
puts "🔒 Main repository (#{repo_path}) remains completely untouched"
|
170
|
+
puts "📝 All changes committed in isolated workspace"
|
171
|
+
|
172
|
+
# Create pull request if auto-create is enabled
|
173
|
+
if should_create_pull_request?
|
174
|
+
pr_url = create_pull_request(healing_branch, branch_name)
|
175
|
+
if pr_url
|
176
|
+
puts "🔗 [WORKSPACE] Pull request created: #{pr_url}"
|
177
|
+
else
|
178
|
+
puts "⚠️ [WORKSPACE] Failed to create pull request, but branch is ready"
|
179
|
+
end
|
158
180
|
else
|
159
|
-
puts "
|
181
|
+
puts "🔍 [WORKSPACE] Review the changes and create a pull request when ready"
|
160
182
|
end
|
183
|
+
|
184
|
+
healing_branch
|
161
185
|
else
|
162
|
-
puts "
|
186
|
+
puts "⚠️ [WORKSPACE] No changes detected in workspace"
|
187
|
+
puts "🔍 This might indicate that:"
|
188
|
+
puts " - The fixes were not applied to the workspace"
|
189
|
+
puts " - There was an issue with the healing process"
|
190
|
+
|
191
|
+
# Delete the empty branch
|
192
|
+
system("git checkout #{branch_name}")
|
193
|
+
system("git branch -D #{healing_branch}")
|
194
|
+
puts "🗑️ [WORKSPACE] Deleted empty healing branch: #{healing_branch}"
|
195
|
+
nil
|
163
196
|
end
|
164
|
-
|
165
|
-
healing_branch
|
166
197
|
end
|
167
198
|
rescue => e
|
168
|
-
puts "❌ Failed to create healing branch: #{e.message}"
|
199
|
+
puts "❌ Failed to create healing branch from workspace: #{e.message}"
|
169
200
|
nil
|
170
201
|
end
|
171
202
|
end
|
@@ -268,10 +299,20 @@ module CodeHealer
|
|
268
299
|
Dir.chdir(repo_path) do
|
269
300
|
current_branch = branch_name || `git branch --show-current`.strip
|
270
301
|
puts "🌿 [WORKSPACE] Current branch: #{current_branch}"
|
271
|
-
puts "🌿 [WORKSPACE] Executing: git clone --single-branch --branch #{current_branch} #{repo_path} #{workspace_path}"
|
272
302
|
|
273
|
-
#
|
274
|
-
|
303
|
+
# Get the GitHub remote URL instead of local path
|
304
|
+
remote_url = `git config --get remote.origin.url`.strip
|
305
|
+
puts "🌿 [WORKSPACE] Remote origin URL: #{remote_url}"
|
306
|
+
|
307
|
+
if remote_url.empty?
|
308
|
+
puts "❌ [WORKSPACE] No remote origin found in #{repo_path}"
|
309
|
+
return false
|
310
|
+
end
|
311
|
+
|
312
|
+
puts "🌿 [WORKSPACE] Executing: git clone --single-branch --branch #{current_branch} #{remote_url} #{workspace_path}"
|
313
|
+
|
314
|
+
# Clone from GitHub remote URL, not local path
|
315
|
+
result = system("git clone --single-branch --branch #{current_branch} #{remote_url} #{workspace_path}")
|
275
316
|
puts "🌿 [WORKSPACE] Clone result: #{result ? 'SUCCESS' : 'FAILED'}"
|
276
317
|
|
277
318
|
if result
|
@@ -291,10 +332,20 @@ module CodeHealer
|
|
291
332
|
Dir.chdir(repo_path) do
|
292
333
|
current_branch = branch_name || `git branch --show-current`.strip
|
293
334
|
puts "🌿 [WORKSPACE] Target branch: #{current_branch}"
|
294
|
-
puts "🌿 [WORKSPACE] Executing: git clone #{repo_path} #{workspace_path}"
|
295
335
|
|
296
|
-
#
|
297
|
-
|
336
|
+
# Get the GitHub remote URL instead of local path
|
337
|
+
remote_url = `git config --get remote.origin.url`.strip
|
338
|
+
puts "🌿 [WORKSPACE] Remote origin URL: #{remote_url}"
|
339
|
+
|
340
|
+
if remote_url.empty?
|
341
|
+
puts "❌ [WORKSPACE] No remote origin found in #{repo_path}"
|
342
|
+
return false
|
343
|
+
end
|
344
|
+
|
345
|
+
puts "🌿 [WORKSPACE] Executing: git clone #{remote_url} #{workspace_path}"
|
346
|
+
|
347
|
+
# Clone from GitHub remote URL, not local path
|
348
|
+
result = system("git clone #{remote_url} #{workspace_path}")
|
298
349
|
puts "🌿 [WORKSPACE] Clone result: #{result ? 'SUCCESS' : 'FAILED'}"
|
299
350
|
|
300
351
|
if result
|
@@ -334,18 +385,10 @@ module CodeHealer
|
|
334
385
|
Dir.glob("**/*.rb")
|
335
386
|
end
|
336
387
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
repo_file = File.join(repo_path, relative_path)
|
342
|
-
|
343
|
-
if File.exist?(repo_file)
|
344
|
-
FileUtils.cp(workspace_file, repo_file)
|
345
|
-
puts "📁 Copied fixed file: #{relative_path}"
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
388
|
+
# This method is no longer needed since we work entirely in the isolated workspace
|
389
|
+
# def copy_fixed_files(workspace_path, repo_path)
|
390
|
+
# # Removed - no longer copying files between directories
|
391
|
+
# end
|
349
392
|
|
350
393
|
def workspace_expired?(workspace_path, hours)
|
351
394
|
return false unless hours && hours > 0
|
data/lib/code_healer/version.rb
CHANGED