Skip to content

Commit

Permalink
Merge branch 'RC_2.3.0-1.3' of ssh://stash.silabs.com/wmn_tools/matte…
Browse files Browse the repository at this point in the history
…r into bringup/917_ncp_with_new_sdk
  • Loading branch information
shgutte committed Jan 11, 2024
2 parents e275616 + ef809c6 commit 2d39211
Show file tree
Hide file tree
Showing 7,724 changed files with 3,027,789 additions and 3,146 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
135 changes: 135 additions & 0 deletions .githooks/pre-commit-smg
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/bin/sh

# This file contains a script to check the modified files within a commit
# against a list of 'untouchable' files that should only be changed within
# the CSA repo.
#
# To set this script to run on each commit, you should locally symlink where
# git looks for this file with this file via a command in project root directory:
# ln -s ../../.githooks/pre-commit-smg .git/hooks/pre-commit
#
# The commit will fail unless checks are passed; to bypass failure you have the
# option to add '--no-verify' tag to your commit.

here=${0%/*}

CHIP_ROOT=$(cd "$here/.." && pwd)

SAVED_UNSTAGED=0
SAVED_UNSTAGED_FILE=$(git rev-parse --short HEAD)-unstaged.diff

save_unstaged() {
if [[ $SAVED_UNSTAGED -ne 0 ]]; then
git diff --output="$SAVED_UNSTAGED_FILE"
git apply -R "$SAVED_UNSTAGED_FILE"
fi
}

revert_unstaged() {
if [[ $SAVED_UNSTAGED -ne 0 ]]; then
git apply "$SAVED_UNSTAGED_FILE"
rm "$SAVED_UNSTAGED_FILE"
fi
SAVED_UNSTAGED=0
}

revert_if_needed() {
revert_unstaged
}

trap "revert_if_needed; exit 1" SIGINT SIGTERM SIGKILL

git diff --quiet
SAVED_UNSTAGED=$?

# If there are unstaged files, save them for now
save_unstaged
revert_if_needed

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

# Redirect output to stderr.
exec 1>&2

# Paths from the repo root of files/directories not to be touched within SMG
MUST_NOT_CHANGE=('.devcontainer'
'build/'
'build_overrides/'
'config/'
'credentials/'
'examples/'
'integrations/'
'scripts/'
'src/'
'third_party/'
'zzz_generated/'
'REVIEWERS.md'
'LICENSE'
'.clang-format'
'.clang-tidy'
'.default-version.min'
'.dir-locals.el'
'.editorconfig'
'.flake8'
'.gitattributes'
'.gitignore'
'.gitmodules'
'.prettierrc.json'
'.pullapprove.yml'
'.restyles.yaml'
'.spellcheck_tree'
'.spellcheck.yml'
'BUILD.gn'
'CODE_OF_CONDUCT.md'
'CONTRIBUTING.md'
'export_examples.sh'
'gn_build.sh'
'lgtm.yml'
'docs/api/'
'docs/discussion/'
'docs/dots/'
'docs/examples/'
'docs/guides'
'docs/images/'
'docs/style/'
'docs/FileBUG_REPORT.md'
'docs/ChipDoxygenLayout.xml'
'docs/Doxyfile'
'docs/namespaces.dox'
'docs/PROJECT_FLOW.md'
'docs/QUICK_START.md'
'docs/README.md'
'docs/STYLE_GUIDE.md'
'docs/VSCODE_DEVELOPMENT.md')

RED='\033[0;31m'
NC='\033[0m'
MATCHING_LIST=()
CHANGED_FILES=$(git diff --cached --name-only $against)

# Search the modified files for changes that should only be made in CSA
# Save these files to be listed along with the commit message
for i in "${MUST_NOT_CHANGE[@]}"; do
MATCH=$(echo "$CHANGED_FILES" | grep "^$i*")
if [[ $MATCH != "" ]]; then
MATCHING_LIST+=$MATCH'\n'
fi
done

# Allow or block commit and list problematic files with warning message
if [ ${#MATCHING_LIST[@]} -eq 0 ]; then
echo "Commit looks good!"
exit 0
else
echo $RED$MATCHING_LIST | tr " " "\n"
echo $NC"Commit failed: You made changes to the listed files which should not be touched within the SMG repo." \
"Are you sure you want to do this?\n"
echo "If so, add justification for making this change in the pull request so the reviewers are aware" \
"and continue with the '--no-verify' tag attached to your commit."
exit 1
fi
17 changes: 17 additions & 0 deletions .githooks/run-all-pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# This file contains a script to to run all pre-commit scripts within this directoy.
#
# To set this script to run on each commit, you should locally symlink where
# git looks for this file with this file via a command in project root directory:
# ln -s ../../.githooks/run-all-pre-commit .git/hooks/pre-commit
#
# The commit will fail unless checks are passed; to bypass failure you have the
# option to add '--no-verify' tag to your commit.

here=${0%/*}
CHIP_ROOT=$(cd "$here/../.." && pwd)

for PRECOMMITSCRIPT in $CHIP_ROOT/.githooks/pre-commit*; do
$PRECOMMITSCRIPT
done
80 changes: 0 additions & 80 deletions .github/ISSUE_TEMPLATE/001-bug-report.yaml

This file was deleted.

98 changes: 0 additions & 98 deletions .github/ISSUE_TEMPLATE/002-1.0-issue.yaml

This file was deleted.

Loading

0 comments on commit 2d39211

Please sign in to comment.