Skip to content

Commit

Permalink
Add prepare-commit-msg (#2688)
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuan0322 committed May 10, 2023
1 parent 90b7e00 commit 81230c5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"settings": {},
"extensions": [
"streetsidesoftware.code-spell-checker",
"eamodio.gitlens"
"eamodio.gitlens",
"github.copilot",
"github.copilot-labs"
]
}
},

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "graphscope"
"remoteUser": "graphscope",

// Uncomment this to enable C++ and Rust debugging in containers
// "capAdd": ["SYS_PTRACE"],
Expand Down Expand Up @@ -61,7 +63,7 @@

// Uncomment these to use a named volume for your entire source tree
// https://code.visualstudio.com/remote/advancedcontainers/improve-performance#_use-a-named-volume-for-your-entire-source-tree
// "workspaceMount": "source=gs,target=/workspace,type=volume",
// "workspaceFolder": "/workspace"
// "postCreateCommand": "sudo chown -R graphscope:graphscope /workspace"
// "workspaceMount": "source=gs,target=/workspaces,type=volume",
// "workspaceFolder": "/workspaces"
"postCreateCommand": "sudo chown -R graphscope /workspaces && bash pre-commit/install-hook.sh && bash pre-commit/prepare-commit-msg"
}
2 changes: 2 additions & 0 deletions pre-commit/install-hook.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

mkdir -p ~/.config/git/hooks/
git config --global core.hooksPath ~/.config/git/hooks/
touch ~/.config/git/hooks/pre-commit
Expand Down
14 changes: 14 additions & 0 deletions pre-commit/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

mkdir -p ~/.config/git/hooks/
git config --global core.hooksPath ~/.config/git/hooks/
touch ~/.config/git/hooks/prepare-commit-msg
chmod +x ~/.config/git/hooks/prepare-commit-msg

cat > ~/.config/git/hooks/prepare-commit-msg << EOF
#!/bin/bash
COMMIT_MSG_FILE=\$1
echo "" >> "\$COMMIT_MSG_FILE"
username=\$(git config --get user.name)
echo "Commited by: \$username from Dev container" >> "\$COMMIT_MSG_FILE"
EOF

0 comments on commit 81230c5

Please sign in to comment.