Skip to content

Commit 07fed37

Browse files
Clean up trailing spaces in JavaScript files and use Open3 for git operations
- Remove trailing spaces from all JavaScript files - Replace Shellwords escaping with Open3 array form in sessions_controller.rb - Update test files to use Open3.capture3 instead of system() calls - Improve safety by using Open3's automatic escaping instead of manual Shellwords
1 parent 5c6e214 commit 07fed37

File tree

52 files changed

+1839
-1772
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1839
-1772
lines changed

app/controllers/sessions_controller.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,8 @@ def diff_file_contents
243243
""
244244
end
245245

246-
# Escape file path for shell
247-
escaped_path = Shellwords.escape(file_path)
248-
249246
# Get git status for this specific file
250-
git_status, _, _ = Open3.capture3("git status --porcelain #{escaped_path}", chdir: safe_dir)
247+
git_status, _, _ = Open3.capture3("git", "status", "--porcelain", file_path, chdir: safe_dir)
251248
git_status = git_status.strip
252249

253250
# Determine file status and get appropriate content
@@ -260,13 +257,13 @@ def diff_file_contents
260257
elsif git_status.match?(/^[AM]M/)
261258
# File has both staged and unstaged changes
262259
# Show HEAD vs working directory (to see all changes)
263-
original_content, _, _ = Open3.capture3("git show HEAD:#{escaped_path}", chdir: safe_dir)
260+
original_content, _, _ = Open3.capture3("git", "show", "HEAD:#{file_path}", chdir: safe_dir)
264261
# modified_content already has the working directory content
265262
elsif git_status.match?(/^[AM]\s/)
266263
# File is only staged (not modified in working directory)
267264
# This means working directory matches staged version
268265
# Show HEAD vs working directory (which equals staged)
269-
original_content, _, status = Open3.capture3("git show HEAD:#{escaped_path}", chdir: safe_dir)
266+
original_content, _, status = Open3.capture3("git", "show", "HEAD:#{file_path}", chdir: safe_dir)
270267
unless status.success?
271268
# New file, show empty vs working directory
272269
original_content = ""
@@ -275,11 +272,11 @@ def diff_file_contents
275272
elsif git_status.match?(/^\sM/)
276273
# File is only modified (not staged)
277274
# Show HEAD vs working directory
278-
original_content, _, _ = Open3.capture3("git show HEAD:#{escaped_path}", chdir: safe_dir)
275+
original_content, _, _ = Open3.capture3("git", "show", "HEAD:#{file_path}", chdir: safe_dir)
279276
# modified_content already has the working directory content
280277
else
281278
# Default: show HEAD vs working directory
282-
original_content, _, _ = Open3.capture3("git show HEAD:#{escaped_path}", chdir: safe_dir)
279+
original_content, _, _ = Open3.capture3("git", "show", "HEAD:#{file_path}", chdir: safe_dir)
283280
# modified_content already has the working directory content
284281
end
285282

app/javascript/controllers/auto_refresh_controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Controller } from "@hotwired/stimulus"
22

33
export default class extends Controller {
4-
static values = {
4+
static values = {
55
interval: { type: Number, default: 3000 }
66
}
77

@@ -16,7 +16,7 @@ export default class extends Controller {
1616
checkAndRefresh() {
1717
// Check if there are any importing projects
1818
const hasImportingProjects = !!this.element.querySelector('[data-import-status="importing"]')
19-
19+
2020
if (hasImportingProjects) {
2121
this.startRefreshing()
2222
} else {

0 commit comments

Comments
 (0)