We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9a528a7 commit 5e45ab7Copy full SHA for 5e45ab7
1 file changed
hooks/dataform_format.sh
@@ -1,2 +1,26 @@
1
-#!/usr/bin/env bash
2
-dataform format
+#!/bin/sh
+
3
+# Check if dataform command is available
4
+if ! command -v dataform >/dev/null 2>&1; then
5
+ echo "Error: dataform command not found. Make sure it is installed and available in PATH."
6
+ exit 1
7
+fi
8
9
+# Get the list of staged files
10
+files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.df$')
11
12
+# Check if there are any Dataform files to format
13
+if [ -z "$files" ]; then
14
+ echo "No Dataform files to format. Skipping pre-commit hook."
15
+ exit 0
16
17
18
+# Run Dataform formatting on each file
19
+echo "Formatting Dataform files..."
20
+for file in $files; do
21
+ dataform fmt $file
22
+ git add $file
23
+done
24
25
+echo "Dataform formatting complete. Please review the changes before committing."
26
+exit 0
0 commit comments