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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f73aedfb97cff3da7cb4a3f62b631886ad5cd377796473b705fe86a6311ff74
4
- data.tar.gz: 9e7ce1d1b49920f763684844e799724078919f657c559d49e96a2784200323d2
3
+ metadata.gz: 4be2602f991eaa2b9952ab40d9b582bb80482b7e1238dfa3b1019649d3a7c67a
4
+ data.tar.gz: c7762eeafe979d09f1620145f46357b822582770095a1ba7bb7be24645818715
5
5
  SHA512:
6
- metadata.gz: 6038730a1146276943b9ec4c7e81569a1977873c303c1b36339b589800d55acd1d05beea95808fc34d71cafc0709cfcaaa0fa1940162f9437087baa5a49f0013
7
- data.tar.gz: 85a7f04e29e7ae8b4ea0cb7e130432d8b5253f7fe6a0e72baa0cd826bbe6a061ee3787a8bcbe7c9080c70b08aebd8c786701aa6940ecffdff57e20e81881baa1
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 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
157
 
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
-
153
- # Create pull request if auto-create is enabled
154
- 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
+ # 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 "⚠️ Failed to create pull request, but branch is ready"
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 "🔍 Review the changes and create a pull request when ready"
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
- # Clone only the current branch
274
- result = system("git clone --single-branch --branch #{current_branch} #{repo_path} #{workspace_path}")
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
- # Clone full repo
297
- result = system("git clone #{repo_path} #{workspace_path}")
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
- 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
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
@@ -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.11"
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.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deepan Kumar