Skip to content

Commit 5e45ab7

Browse files
author
Hugo Rialan
committed
test
1 parent 9a528a7 commit 5e45ab7

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

hooks/dataform_format.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
#!/usr/bin/env bash
2-
dataform format
1+
#!/bin/sh
2+
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+
fi
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

Comments
 (0)