Merge branch 'dev' of lab.si.usi.ch:sa4-2020/the-sanmarinoes/backend into data-model-feature

This commit is contained in:
Claudio Maggioni 2020-02-24 14:19:06 +01:00
commit e932c5cf58
6 changed files with 57 additions and 8 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="13" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="12" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

14
git-hooks/format.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh -e
jar_version=1.6
jar_dir="$HOME/.local/share/java"
jar_file="$jar_dir/google-java-format-$jar_version-all-deps.jar"
java_cmd="java"
# download jar file if missing
if [ ! -f "$jar_file" ]; then
mkdir -p "$jar_dir"
wget -O "$jar_file" https://github.com/google/google-java-format/releases/download/google-java-format-$jar_version/google-java-format-$jar_version-all-deps.jar
fi
# execute formatter
$java_cmd -jar "$jar_file" $@

18
git-hooks/pre-commit.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh
set -e
echo "Java formatter running..."
format_cmd="$(dirname $(realpath "$0"))/format.sh"
# skip if NO_VERIFY env var set
if [ "$NO_VERIFY" ]; then
echo 'google-java-format skipped' 1>&2
exit 0
fi
# list all added/copied/modified/renamed java files
git diff --staged --name-only --diff-filter=ACMR | egrep -a '.java$' | tr "\n" "\0" |
# run google-java-format on each file and re-stage any new changes
xargs -0 -I % echo "$format_cmd --aosp -i '%'; git add -f '%'" | sh

19
git-hooks/setup.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh
if ! git remote get-url origin | grep "lab.si.usi.ch" >/dev/null 2>/dev/null; then
echo "Not in the project!"
echo "Call this script while in the root directory of the backend project";
exit 1;
elif ! [ -d "./git-hooks" ]; then
echo "Not in the right directory!"
echo "Call this script while in the root directory of the backend project";
exit 1;
fi;
git config --unset core.hooksPath
this_dir="$(dirname $(realpath "$0"))"
hook_script="$this_dir/pre-commit.sh"
ln -svf "$hook_script" "$this_dir/../.git/hooks/pre-commit"
echo "Commit hook installed"

View file

@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SmarthutApplication {
public static void main(String[] args) {
SpringApplication.run(SmarthutApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(SmarthutApplication.class, args);
}
}

View file

@ -6,8 +6,6 @@ import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SmarthutApplicationTests {
@Test
void contextLoads() {
}
@Test
void contextLoads() {}
}