Skip to content

Commit

Permalink
REPO: Add devcontainer configuraiton
Browse files Browse the repository at this point in the history
This commit allows for a codespace to be created with the pre
configured commit hooks, codespell, and clang-format.
  • Loading branch information
mkmer authored Jan 25, 2025
1 parent e4dee90 commit de619eb
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "allStarLink Dev",
"image": "mcr.microsoft.com/devcontainers/cpp:dev-debian12",
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"postStartCommand": "git config --global core.hooksPath ${containerWorkspaceFolder}/dev/",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
"packages": "codespell,clang-format"
}
},
"customizations": {
"vscode": {
"extensions": [
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"ms-vscode.cpptools-extension-pack",
"GitHub.vscode-pull-request-github"
],
"settings": {
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.trimTrailingWhitespace": true,
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
},
"terminal.integrated.defaultProfile.linux": "zsh"
}
}
}
}
42 changes: 42 additions & 0 deletions dev/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi

# Test clang-format
clangformatout=$(git clang-format --style=file:./dev/.clang-format --diff --staged -q)

# Redirect output to stderr.
exec 1>&2

if [ "$clangformatout" != "" ]
then
echo "Format error!"
echo "Use git clang-format"
exit 1
fi

codespell=$(codespell --skip="./.git" --ignore-words=./dev/.codespellignore)

exec 1>&2

if [ "$codespell" != "" ]
then
echo "Spelling errors!"
echo "Run codespell"
echo $codespell
exit 1
fi

0 comments on commit de619eb

Please sign in to comment.