Skip to main content
summaryrefslogtreecommitdiffstats
path: root/releng
diff options
context:
space:
mode:
Diffstat (limited to 'releng')
-rwxr-xr-xreleng/scripts/apply_jdt_prefs_to_all_projects.sh14
-rwxr-xr-xreleng/scripts/check_code_cleanliness.sh76
-rwxr-xr-xreleng/scripts/verify_gitattributes.sh22
3 files changed, 76 insertions, 36 deletions
diff --git a/releng/scripts/apply_jdt_prefs_to_all_projects.sh b/releng/scripts/apply_jdt_prefs_to_all_projects.sh
deleted file mode 100755
index dee33a0d9a..0000000000
--- a/releng/scripts/apply_jdt_prefs_to_all_projects.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-for i in `find . -name .project`; do
- d=`dirname $i`;
- if test ! -e $d/feature.xml; then
- mkdir -p $d/.settings
- cp core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.* core/org.eclipse.cdt.core/.settings/org.eclipse.pde.* $d/.settings
- # For test plug-ins, don't warn on missing NLS
- if echo $i | grep '\.tests[/\.]' > /dev/null; then
- sed -i '-es@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore@' $d/.settings/org.eclipse.jdt.core.prefs
- fi
- fi
-done
-
diff --git a/releng/scripts/check_code_cleanliness.sh b/releng/scripts/check_code_cleanliness.sh
new file mode 100755
index 0000000000..f33b61119d
--- /dev/null
+++ b/releng/scripts/check_code_cleanliness.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+###
+# This script is run automatically as part of gerrit validation jobs
+# to ensure that coding standards have been followed. It can also be
+# used to make code follow standards again.
+#
+# The overall design is to apply a number of fixes (formatting, trim
+# whitespace, etc) and then check if there are any modifications
+# in git.
+###
+
+set -e
+
+##
+# Format code
+##
+: ${ECLIPSE:=~/buildtools/eclipse-SDK-4.9/eclipse}
+test ! -e check_code_cleanliness_workspace
+${ECLIPSE} \
+ -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \
+ -config $PWD/core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.core.prefs \
+ $PWD -data check_code_cleanliness_workspace
+rm -rf check_code_cleanliness_workspace
+
+##
+# Remove trailing whitespace.
+# The .gitattributes is used as a filter to identify files to check. Patters with
+# this "# check trailing whitespace" on the line before are checked
+##
+awk '/# remove trailing whitespace/{getline; print $1}' .gitattributes | \
+ while read i ; do \
+ echo "Removing trailing whitespace on $i files"
+ find . ! -path "./.git/*" -type f -name "$i" -exec sed -i 's/[ \t]*$//' {} +; \
+ done
+
+##
+# Add all file types to .gitattributes
+##
+find . ! -path "./.git/*" -type f -printf "%f\n" | sed -E -e 's/.+\./\\\*\\./' | sort -u | while read i ; do
+ if ! grep "^$i " .gitattributes > /dev/null
+ then
+ echo "MISSING $i in .gitattributes, adding as text, check if that is correct"
+ echo "$i text # automatically added - please verify" >> .gitattributes
+ fi
+done
+
+##
+# Copy JDT/PDE preferences
+##
+find . ! -path "./.git/*" -name .project ! -path './core/org.eclipse.cdt.core/.project' | while read i ; do
+ d=`dirname $i`;
+ if test ! -e $d/feature.xml; then
+ mkdir -p $d/.settings
+ cp core/org.eclipse.cdt.core/.settings/org.eclipse.jdt.* core/org.eclipse.cdt.core/.settings/org.eclipse.pde.* $d/.settings
+ # For test plug-ins, don't warn on missing NLS
+ if echo $i | grep '\.tests[/\.]' > /dev/null; then
+ sed -i '-es@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning@org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore@' $d/.settings/org.eclipse.jdt.core.prefs
+ fi
+ fi
+done
+
+##
+# Check that none of the above caused any changes
+##
+if test -z "$(git status -s)"; then
+ echo "Tree looks clean!"
+else
+ echo "Tree is dirty - something needs to be cleaned up in your commit"
+ echo "Result of git status"
+ git status
+ echo "Result of git diff"
+ git diff
+ echo "Tree is dirty - something needs to be cleaned up in your commit (see above for git status/diff)"
+ exit 1
+fi
diff --git a/releng/scripts/verify_gitattributes.sh b/releng/scripts/verify_gitattributes.sh
deleted file mode 100755
index 2f5a58c044..0000000000
--- a/releng/scripts/verify_gitattributes.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-
-# Print out how many of each file extension there is
-# find . ! -path "./.git/*" -type f -printf "%f\n" | sed -E -e 's/.+\./\*./' | sort -u | while read i; do find . ! -path "./.git/*" -name $i | wc -l | tr -d '\n'; echo " : $i" ; done | sort -n
-
-# Print out all the unique file extensions, including unique names with no extension
-# Each of these should be in .gitattributes
-# find . ! -path "./.git/*" -type f -printf "%f\n" | sed -E -e 's/.+\./\*./' | sort -u
-
-find . ! -path "./.git/*" -type f -printf "%f\n" | sed -E -e 's/.+\./\\\*\\./' | sort -u | while read i
-do
- echo -n "Checking $i in .gitattributes: "
- if grep "^$i " .gitattributes
- then
- echo "Found"
- else
- echo MISSING $i in .gitattributes. List of file:
- find . ! -path "./.git/*" -type f -name "$i"
- exit 1
- fi
-done
-

Back to the top