Skip to content

Commit

Permalink
Add git pre-commit hook to source control (apache#9554)
Browse files Browse the repository at this point in the history
* Add git pre-commit hook to source control

* Changed hook to pre-push and simply hook to run all checkstyle

* Clean up setup-hooks

* Add apache header

* Add apache header

* add documentation to intellij-setup.md

* retrigger tests

* update

Co-authored-by: Maytas Monsereenusorn <[email protected]>
  • Loading branch information
maytasm and maytasm authored Jun 5, 2020
1 parent bcc066a commit 45b699f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dev/intellij-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ an alias name. You can do this in Using `File` -> `Project Structure...` -> `Pla
## Code Style
The Code Style is available in XML format at [druid_intellij_formatting.xml](druid_intellij_formatting.xml) and can be [imported into IntelliJ](https://www.jetbrains.com/help/idea/2017.1/copying-code-style-settings.html).

## Git Checkstyle Verification Hook (Optional)
Git Checkstyle pre-commit hook can be installed to automatically run checkstyle verification before committing,
saving cycle from avoiding the checkstyle failing later in Travis/CI environment.
The hook can be setup easily by running the <DRUID_HOME>/setup-hooks.sh script.

## Metadata
The installation of a MySQL metadata store is outside the scope of this document, but instructions on setting up MySQL can be found at [docs/development/extensions-core/mysql.md](/docs/development/extensions-core/mysql.md). This assumes you followed the example there and have a database named `druid` with proper permissions for a user named `druid` and a password of `diurd`.

Expand Down
17 changes: 17 additions & 0 deletions hooks/pre-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -eu
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

mvn checkstyle:checkstyle --fail-at-end
17 changes: 17 additions & 0 deletions setup-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -eu
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ln -s ../../hooks/pre-push.sh .git/hooks/pre-push

0 comments on commit 45b699f

Please sign in to comment.