code_healer 0.1.8 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f73aedfb97cff3da7cb4a3f62b631886ad5cd377796473b705fe86a6311ff74
4
- data.tar.gz: 9e7ce1d1b49920f763684844e799724078919f657c559d49e96a2784200323d2
3
+ metadata.gz: 4c3f51b2e61939becd7c68f57c2f70cb9dacf3b98f8ff62cfa2b3593dc745cfe
4
+ data.tar.gz: 8acbfcd6a4e3abae5cb96a2f451c01f6dc8ac40ada877fba4ed673962e87ab83
5
5
  SHA512:
6
- metadata.gz: 6038730a1146276943b9ec4c7e81569a1977873c303c1b36339b589800d55acd1d05beea95808fc34d71cafc0709cfcaaa0fa1940162f9437087baa5a49f0013
7
- data.tar.gz: 85a7f04e29e7ae8b4ea0cb7e130432d8b5253f7fe6a0e72baa0cd826bbe6a061ee3787a8bcbe7c9080c70b08aebd8c786701aa6940ecffdff57e20e81881baa1
6
+ metadata.gz: 892a29730e66d2e207460dd2ede2c93b42114760a509ff05b7e17b5a28545ecb7fe1be0078d16cf7ff1f88a106a99d9e20af8ffd0baa53b8442ce2898363e1e0
7
+ data.tar.gz: a89f5fccbc969fd0eccc468896c0ff0532868fb9ceb6a22a1e731319f2da2f602e2917f61add01424ea4c1fb869fef47d28b7e78e379d0c52d02e9666e65663e
data/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ 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.12] - 2025-01-14
9
+
10
+ ### Fixed
11
+ - **Duplicate PR creation** - Prevents duplicate pull requests when evolution handler already creates one
12
+ - **PR workflow optimization** - Skips redundant PR creation in healing workspace manager
13
+
14
+ ## [0.1.11] - 2025-01-14
15
+
16
+ ### Fixed
17
+ - **Repository cloning** - Now clones from GitHub remote URL instead of local path
18
+ - **Git remote configuration** - Ensures workspace has correct GitHub remote for PR creation
19
+ - **Debug information** - Added Git remote and branch debugging in workspace operations
20
+
21
+ ## [0.1.10] - 2025-01-14
22
+
23
+ ### Changed
24
+ - **Complete workspace isolation** - All Git operations now happen in isolated workspace only
25
+ - **No file copying** - Removed file copying between workspace and main repo
26
+ - **Direct PR creation** - Pull requests are created directly from the isolated workspace
27
+ - **Main repo protection** - Main repository is never touched, only the isolated workspace
28
+
29
+ ### Fixed
30
+ - **Git commit workflow** - Added proper change detection before committing
31
+ - **Empty branch prevention** - Delete healing branches when no changes are detected
32
+ - **Enhanced debugging** - Added Git status and diff logging throughout the process
33
+
8
34
  ## [0.1.8] - 2025-01-14
9
35
 
10
36
  ### 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,72 @@ module CodeHealer
121
129
  end
122
130
 
123
131
  def create_healing_branch(repo_path, workspace_path, branch_name)
124
- puts "🔄 Creating healing branch for code review"
132
+ puts "🔄 Creating healing branch and PR from isolated workspace"
125
133
 
126
134
  begin
127
- # Create healing branch in main repo
128
- Dir.chdir(repo_path) do
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
- # Copy fixed files from workspace to the new branch
138
- # This is safe as we're on a new branch, not the main branch
139
- copy_fixed_files(workspace_path, repo_path)
151
+ # Check Git status
152
+ puts "📊 [WORKSPACE] Git status in workspace:"
153
+ system("git status --porcelain")
140
154
 
141
- # Commit changes to the healing branch
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
-
149
- puts "✅ Healing branch created: #{healing_branch}"
150
- puts "🔒 Main branch (#{branch_name}) remains unchanged"
151
- puts "📝 Changes are now available in branch: #{healing_branch}"
152
157
 
153
- # Create pull request if auto-create is enabled
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 and no PR was already created
154
173
  if should_create_pull_request?
155
- pr_url = create_pull_request(healing_branch, branch_name)
156
- if pr_url
157
- puts "🔗 Pull request created: #{pr_url}"
158
- else
159
- puts "⚠️ Failed to create pull request, but branch is ready"
160
- end
174
+ puts "🔍 [WORKSPACE] Checking if PR was already created by evolution handler..."
175
+ # Skip PR creation if we're in a healing workflow (PR likely already created)
176
+ puts "🔍 [WORKSPACE] PR creation skipped - likely already created by evolution handler"
177
+ puts "🔍 [WORKSPACE] Review the changes and create a pull request when ready"
161
178
  else
162
- puts "🔍 Review the changes and create a pull request when ready"
179
+ puts "🔍 [WORKSPACE] Review the changes and create a pull request when ready"
180
+ end
181
+
182
+ healing_branch
183
+ else
184
+ puts "⚠️ [WORKSPACE] No changes detected in workspace"
185
+ puts "🔍 This might indicate that:"
186
+ puts " - The fixes were not applied to the workspace"
187
+ puts " - There was an issue with the healing process"
188
+
189
+ # Delete the empty branch
190
+ system("git checkout #{branch_name}")
191
+ system("git branch -D #{healing_branch}")
192
+ puts "🗑️ [WORKSPACE] Deleted empty healing branch: #{healing_branch}"
193
+ nil
163
194
  end
164
-
165
- healing_branch
166
195
  end
167
196
  rescue => e
168
- puts "❌ Failed to create healing branch: #{e.message}"
197
+ puts "❌ Failed to create healing branch from workspace: #{e.message}"
169
198
  nil
170
199
  end
171
200
  end
@@ -268,10 +297,20 @@ module CodeHealer
268
297
  Dir.chdir(repo_path) do
269
298
  current_branch = branch_name || `git branch --show-current`.strip
270
299
  puts "🌿 [WORKSPACE] Current branch: #{current_branch}"
271
- puts "🌿 [WORKSPACE] Executing: git clone --single-branch --branch #{current_branch} #{repo_path} #{workspace_path}"
272
300
 
273
- # Clone only the current branch
274
- result = system("git clone --single-branch --branch #{current_branch} #{repo_path} #{workspace_path}")
301
+ # Get the GitHub remote URL instead of local path
302
+ remote_url = `git config --get remote.origin.url`.strip
303
+ puts "🌿 [WORKSPACE] Remote origin URL: #{remote_url}"
304
+
305
+ if remote_url.empty?
306
+ puts "❌ [WORKSPACE] No remote origin found in #{repo_path}"
307
+ return false
308
+ end
309
+
310
+ puts "🌿 [WORKSPACE] Executing: git clone --single-branch --branch #{current_branch} #{remote_url} #{workspace_path}"
311
+
312
+ # Clone from GitHub remote URL, not local path
313
+ result = system("git clone --single-branch --branch #{current_branch} #{remote_url} #{workspace_path}")
275
314
  puts "🌿 [WORKSPACE] Clone result: #{result ? 'SUCCESS' : 'FAILED'}"
276
315
 
277
316
  if result
@@ -291,10 +330,20 @@ module CodeHealer
291
330
  Dir.chdir(repo_path) do
292
331
  current_branch = branch_name || `git branch --show-current`.strip
293
332
  puts "🌿 [WORKSPACE] Target branch: #{current_branch}"
294
- puts "🌿 [WORKSPACE] Executing: git clone #{repo_path} #{workspace_path}"
295
333
 
296
- # Clone full repo
297
- result = system("git clone #{repo_path} #{workspace_path}")
334
+ # Get the GitHub remote URL instead of local path
335
+ remote_url = `git config --get remote.origin.url`.strip
336
+ puts "🌿 [WORKSPACE] Remote origin URL: #{remote_url}"
337
+
338
+ if remote_url.empty?
339
+ puts "❌ [WORKSPACE] No remote origin found in #{repo_path}"
340
+ return false
341
+ end
342
+
343
+ puts "🌿 [WORKSPACE] Executing: git clone #{remote_url} #{workspace_path}"
344
+
345
+ # Clone from GitHub remote URL, not local path
346
+ result = system("git clone #{remote_url} #{workspace_path}")
298
347
  puts "🌿 [WORKSPACE] Clone result: #{result ? 'SUCCESS' : 'FAILED'}"
299
348
 
300
349
  if result
@@ -334,18 +383,10 @@ module CodeHealer
334
383
  Dir.glob("**/*.rb")
335
384
  end
336
385
 
337
- def copy_fixed_files(workspace_path, repo_path)
338
- # Copy all Ruby files from workspace to repo
339
- Dir.glob(File.join(workspace_path, "**/*.rb")).each do |workspace_file|
340
- relative_path = workspace_file.sub(workspace_path + "/", "")
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
386
+ # This method is no longer needed since we work entirely in the isolated workspace
387
+ # def copy_fixed_files(workspace_path, repo_path)
388
+ # # Removed - no longer copying files between directories
389
+ # end
349
390
 
350
391
  def workspace_expired?(workspace_path, hours)
351
392
  return false unless hours && hours > 0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CodeHealer
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.12"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_healer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deepan Kumar