Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for the expected --about argument
- Loading branch information
1 parent
5b4f4b5
commit 6e3c88a
Showing
2 changed files
with
85 additions
and
46 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 |
---|---|---|
@@ -1,35 +1,54 @@ | ||
#!/bin/sh | ||
|
||
# Create a .png of the gschem .sch files in the repository | ||
sch_files=`git diff-index --cached --name-only HEAD | egrep -i "*.sch$"` | ||
for file in $sch_files | ||
do | ||
image_file=`echo "$file" | sed "s/\.sch/.png/"` | ||
image_file_base=`basename "$image_file"` | ||
echo "Creating $image_file from $file" | ||
image_script_base="image.scm" | ||
image_script="" | ||
image_script0="`pwd`/git_hooks/resources/$image_script_base" | ||
image_script1="~/.git_hooks/resources/$image_script_base" | ||
image_script2="`which gschem | sed 's|bin/gschem|share/gEDA/scheme/|'`$image_script_base" | ||
# TODO: check the default install of gschem (/usr/share/gEDA/scheme/image.scm in Arch Linux) | ||
if [ -f "$image_script0" ] | ||
then | ||
image_script="$image_script0" | ||
elif [ -f "$image_script1" ] | ||
then | ||
image_script="$image_script1" | ||
elif [ -f "$image_script2" ] | ||
then | ||
image_script="$image_script2" | ||
else | ||
echo "Error: could not find '$image_script_base' for gschem image generation" | ||
exit 1 | ||
fi | ||
echo " Using $image_script" | ||
function run_test | ||
{ | ||
# Create a .png of the gschem .sch files in the repository | ||
sch_files=`git diff-index --cached --name-only HEAD | egrep -i "*.sch$"` | ||
for file in $sch_files | ||
do | ||
image_file=`echo "$file" | sed "s/\.sch/.png/"` | ||
image_file_base=`basename "$image_file"` | ||
echo "Creating $image_file from $file" | ||
image_script_base="image.scm" | ||
image_script="" | ||
image_script0="`pwd`/git_hooks/resources/$image_script_base" | ||
image_script1="~/.git_hooks/resources/$image_script_base" | ||
image_script2="`which gschem | sed 's|bin/gschem|share/gEDA/scheme/|'`$image_script_base" | ||
# TODO: check the default install of gschem (/usr/share/gEDA/scheme/image.scm in Arch Linux) | ||
if [ -f "$image_script0" ] | ||
then | ||
image_script="$image_script0" | ||
elif [ -f "$image_script1" ] | ||
then | ||
image_script="$image_script1" | ||
elif [ -f "$image_script2" ] | ||
then | ||
image_script="$image_script2" | ||
else | ||
echo "Error: could not find '$image_script_base' for gschem image generation" | ||
exit 1 | ||
fi | ||
echo " Using $image_script" | ||
|
||
gschem -p -o "$image_file_base" -s "$image_script" "$file" | ||
gschem -p -o "$image_file_base" -s "$image_script" "$file" | ||
|
||
echo "Adding image files to staging area" | ||
git add $image_file | ||
done | ||
} | ||
|
||
case "${1}" in | ||
--about ) | ||
echo -n "Include .png versions of all changed schematics in commits using gschem which is: " | ||
which gschem > /dev/null | ||
if [ ! $? -eq 0 ] ; then | ||
echo "not installed" | ||
else | ||
echo "installed" | ||
fi | ||
;; | ||
* ) | ||
run_test "$@" | ||
;; | ||
esac | ||
|
||
echo "Adding image files to staging area" | ||
git add $image_file | ||
done |
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 |
---|---|---|
@@ -1,19 +1,39 @@ | ||
#!/bin/sh | ||
|
||
# Create a .png of the front and back of all gEDA PCB .pcb files in the repository | ||
DPI=600 | ||
pcb_files=`git diff-index --cached --name-only HEAD | egrep -i "*.pcb$"` | ||
for file in $pcb_files | ||
do | ||
front_png_file=`echo "$file" | sed "s/\.pcb/_front.png/"` | ||
echo "Creating $front_png_file from $file" | ||
pcb -x png --dpi $DPI --use-alpha --photo-mode --outfile $front_png_file $file | ||
function run_test | ||
{ | ||
# Create a .png of the front and back of all gEDA PCB .pcb files in the repository | ||
DPI=600 | ||
pcb_files=`git diff-index --cached --name-only HEAD | egrep -i "*.pcb$"` | ||
for file in $pcb_files | ||
do | ||
front_png_file=`echo "$file" | sed "s/\.pcb/_front.png/"` | ||
echo "Creating $front_png_file from $file" | ||
pcb -x png --dpi $DPI --use-alpha --photo-mode --outfile $front_png_file $file | ||
|
||
back_png_file=`echo "$file" | sed "s/\.pcb/_back.png/"` | ||
echo "Creating $back_png_file from $file" | ||
pcb -x png --dpi $DPI --use-alpha --photo-mode --photo-flip-x --outfile $back_png_file $file | ||
|
||
echo "Adding PNGs to staging area" | ||
git add $front_png_file | ||
git add $back_png_file | ||
done | ||
} | ||
|
||
case "${1}" in | ||
--about ) | ||
echo -n "Include .png versions of all changed schematics in commits using gschem which is: " | ||
which gschem > /dev/null | ||
if [ ! $? -eq 0 ] ; then | ||
echo "not installed" | ||
else | ||
echo "installed" | ||
fi | ||
;; | ||
* ) | ||
run_test "$@" | ||
;; | ||
esac | ||
|
||
back_png_file=`echo "$file" | sed "s/\.pcb/_back.png/"` | ||
echo "Creating $back_png_file from $file" | ||
pcb -x png --dpi $DPI --use-alpha --photo-mode --photo-flip-x --outfile $back_png_file $file | ||
|
||
echo "Adding PNGs to staging area" | ||
git add $front_png_file | ||
git add $back_png_file | ||
done |