Skip to content

Commit b13441e

Browse files
committed
Debug
1 parent b2c54fe commit b13441e

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

.github/workflows/clang-format.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@ jobs:
5050
bin/setup
5151
- name: Check C code formatting
5252
run: |
53+
clang-format --version
5354
bundle exec rake templates
54-
bundle exec rake format:c_check
55+
bundle exec rake format:c_verbose || (echo "Run 'rake format:c' locally to fix these issues" && exit 1)

Rakefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,47 @@ namespace :format do
119119
puts "✅ All files are properly formatted"
120120
end
121121
end
122+
123+
desc "Verbose check of C source files formatting with diff output"
124+
task :c_verbose do
125+
puts "Checking C file formatting (verbose)..."
126+
127+
# Check if clang-format is installed
128+
unless system("which clang-format > /dev/null 2>&1")
129+
abort "Error: clang-format not found. Please install clang-format first."
130+
end
131+
132+
if files.empty?
133+
puts "No C files found to check"
134+
next
135+
end
136+
137+
puts "Found #{files.length} files to check (excluding generated files)"
138+
139+
needs_format = false
140+
files.each do |file|
141+
formatted = `clang-format -style=file #{file}`
142+
original = File.read(file)
143+
144+
if formatted != original
145+
puts "❌ #{file} needs formatting"
146+
puts "Diff:"
147+
# Save formatted version to temp file and run diff
148+
temp_file = "#{file}.formatted"
149+
File.write(temp_file, formatted)
150+
system("diff -u #{file} #{temp_file}")
151+
File.unlink(temp_file)
152+
needs_format = true
153+
end
154+
end
155+
156+
if needs_format
157+
warn "Some files need formatting. Run 'rake format:c' to format them."
158+
exit 1
159+
else
160+
puts "✅ All files are properly formatted"
161+
end
162+
end
122163
end
123164

124165
rule ".c" => ".re" do |t|

0 commit comments

Comments
 (0)