Skip to content

Commit

Permalink
Added support for the expected --about argument
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBergman committed Jul 8, 2012
1 parent 5b4f4b5 commit 6e3c88a
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 46 deletions.
81 changes: 50 additions & 31 deletions pre-commit/gEDA-gschem-image
@@ -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
50 changes: 35 additions & 15 deletions pre-commit/gEDA-pcb-image
@@ -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

0 comments on commit 6e3c88a

Please sign in to comment.