mirror of
https://github.com/Leonmmcoset/cleonos.git
synced 2026-04-21 10:40:00 +00:00
代码检测
This commit is contained in:
14
.clang-format
Normal file
14
.clang-format
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
ColumnLimit: 120
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
PointerAlignment: Right
|
||||||
|
SortIncludes: Never
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
...
|
||||||
50
.github/workflows/style-check.yml
vendored
Normal file
50
.github/workflows/style-check.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name: Code Style Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
clang-format:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install clang-format
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y clang-format
|
||||||
|
|
||||||
|
- name: Check C/C++ style
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
mapfile -t files < <(
|
||||||
|
git ls-files \
|
||||||
|
'*.c' '*.h' '*.cc' '*.cpp' '*.cxx' '*.hpp' '*.hxx' \
|
||||||
|
| grep -Ev '^(limine/|third_party/|build/|build-cmake/)' || true
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ ${#files[@]} -eq 0 ]]; then
|
||||||
|
echo "No C/C++ files to check."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for f in "${files[@]}"; do
|
||||||
|
clang-format -i "$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! git diff --quiet -- "${files[@]}"; then
|
||||||
|
echo "Code style check failed. Please run clang-format on changed files."
|
||||||
|
echo ""
|
||||||
|
git diff -- "${files[@]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Code style check passed."
|
||||||
@@ -624,7 +624,7 @@ CLKS_NORETURN void clks_panic(const char *reason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clks_panic_emit_backtrace(&console, rip, rbp, rsp);
|
clks_panic_emit_backtrace(&console, rip, rbp, rsp);
|
||||||
clks_panic_console_write(&console, "\nSystem halted. Please reboot the VM.\n");
|
clks_panic_console_write(&console, "\nSystem halted. Please reboot the computer.\n");
|
||||||
} else {
|
} else {
|
||||||
clks_panic_emit_backtrace(CLKS_NULL, rip, rbp, rsp);
|
clks_panic_emit_backtrace(CLKS_NULL, rip, rbp, rsp);
|
||||||
}
|
}
|
||||||
@@ -691,7 +691,7 @@ CLKS_NORETURN void clks_panic_exception(const char *name,
|
|||||||
clks_panic_console_write(&console, "\n");
|
clks_panic_console_write(&console, "\n");
|
||||||
|
|
||||||
clks_panic_emit_backtrace(&console, rip, rbp, rsp);
|
clks_panic_emit_backtrace(&console, rip, rbp, rsp);
|
||||||
clks_panic_console_write(&console, "\nSystem halted. Please reboot the VM.\n");
|
clks_panic_console_write(&console, "\nSystem halted. Please reboot the computer.\n");
|
||||||
} else {
|
} else {
|
||||||
clks_panic_emit_backtrace(CLKS_NULL, rip, rbp, rsp);
|
clks_panic_emit_backtrace(CLKS_NULL, rip, rbp, rsp);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user