forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
239ced0
commit 71cf5a7
Showing
1 changed file
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# Define the folder to exclude | ||
EXCLUDE_DIR="./war/work" | ||
|
||
# Set the number of spaces for indentation | ||
INDENT_SPACES="2" | ||
|
||
# Find all .jelly files, excluding the war/work directory | ||
find . -name "*.jelly" -not -path "$EXCLUDE_DIR/*" | while read -r file; do | ||
echo "Processing and indenting $file" | ||
|
||
# Temporary file to store reformatted output | ||
TEMP_FILE="$file.tmp" | ||
|
||
# Separate the copyright comment (if it exists) | ||
awk 'NR==1,/-->/ {print > "'$TEMP_FILE'.header"; next} {print > "'$TEMP_FILE'"}' "$file" | ||
|
||
# Re-indent the non-header part of the file (replace leading tabs with spaces) | ||
perl -pe 's/^\t+/(" " x (length($&)*'$INDENT_SPACES'))/e' "$TEMP_FILE" > "$TEMP_FILE.indented" | ||
|
||
# Combine the header and the indented body | ||
if [ -f "$TEMP_FILE.header" ]; then | ||
cat "$TEMP_FILE.header" "$TEMP_FILE.indented" > "$file" | ||
rm "$TEMP_FILE.header" | ||
else | ||
mv "$TEMP_FILE.indented" "$file" | ||
fi | ||
|
||
# Clean up temporary files | ||
rm "$TEMP_FILE" "$TEMP_FILE.indented" | ||
|
||
done | ||
|
||
echo "All applicable .jelly files have been correctly indented, excluding the war/work directory and preserving copyright comments." |