This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Git Hooks + dev exp improvements (#2536)
* Delete some unused code * Remove "Final Steps" from the PR template * Prevent duplicate PR runs * Add detektFormat `pre-push` hook * Add instructions to setup `.git/hooks` * Test the pre-push hook * Hook test #1 * WIP: Fix pre-push hook and detektFormat.sh * Generate a new baseline.yml * Fix the `lint` workflow to always upload Lint and Detekt result * Fix the detekt/baselin.yml AS auto-format breaks it
- Loading branch information
1 parent
cc5e51d
commit d90bcbf
Showing
14 changed files
with
85 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
./gradlew detektFormat | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Detekt found issues. Aborting push." | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Fetch changed and untracked Kotlin files | ||
CHANGED_FILES=$(git diff --name-only HEAD | grep '\.kt[s]*$' | tr '\n' ',') | ||
|
||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "No Kotlin files have changed." | ||
exit 0 | ||
fi | ||
|
||
# Run detektFormat only on those files | ||
./gradlew detektFormat -Ddetekt.filesToCheck=$CHANGED_FILES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# scripts/init.sh | ||
|
||
# Define directories | ||
HOOKS_DIR="git/hooks" | ||
GIT_HOOKS_DIR=".git/hooks" | ||
BASE_DIR="$(pwd)" | ||
|
||
# Check if the .git directory exists | ||
if [ ! -d "$GIT_HOOKS_DIR" ]; then | ||
echo "Error: This script should be run from the root of the git repository." | ||
exit 1 | ||
fi | ||
|
||
# Set up symbolic link for pre-push hook | ||
ln -s -f $BASE_DIR/$HOOKS_DIR/pre-push $GIT_HOOKS_DIR/pre-push | ||
echo "pre-push hook has been set up." | ||
|
||
# Ensure the pre-push hook is executable | ||
chmod +x $GIT_HOOKS_DIR/pre-push | ||
echo "pre-push hook is now executable." | ||
|
||
chmod +x /script/detektFormat.sh | ||
echo "scripts in '/scripts' are now executable." | ||
|
||
echo "Repository setup complete!" |