Skip to main content
Sign in
Snippets Groups Projects
Commit cbc3e88f authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Symlink script instead of copying them

parent d99f1815
No related branches found
No related tags found
No related merge requests found
......@@ -2,29 +2,24 @@
shopt -s nullglob
kicad-sch-filter() {
cat $(realpath $(dirname $0)/kicad-sch-filter)
}
kicad-pro-filter() {
cat $(realpath $(dirname $0)/kicad-pro-filter)
}
mkdir -p ~/.config/git
for s in kicad-pro-filter kicad-sch-filter ; do
if ! declare -f -F $s > /dev/null ; then
echo "${s} not defined"
continue
FILTER=$(realpath $(dirname $0)/kicad-sch-filter)
if [ -L ~/.config/git/${s} ] ; then
if [ $(readlink ~/.config/git/${s}) != ${FILTER} ] ; then
echo REPLACE link
rm ~/.config/git/${s}
fi
elif [ -f ~/.config/git/${s} ] ; then
if diff -q <($s) <(cat ~/.config/git/${s}) ; then
echo REPLACE file
rm ~/.config/git/${s}
fi
if [ ! -f ~/.config/git/${s} ] ; then
echo "Creating ~/.config/git/${s}"
cat <($s) > ~/.config/git/${s}
chmod +x ~/.config/git/${s}
elif ! diff <($s) <(cat ~/.config/git/${s}) > /dev/null ; then
echo "Updating ~/.config/git/${s}"
cat <($s) > ~/.config/git/${s}
chmod +x ~/.config/git/${s}
fi
if [ ! -L ~/.config/git/${s} ] ; then
ln -s $FILTER ~/.config/git/${s}
fi
done
SCHEMATICS=( *.sch )
......@@ -52,7 +47,7 @@ for s in ${PROJECT[@]} ; do
if [[ "$s" =~ (.*)\.pro ]] ; then
BASE=${BASH_REMATCH[1]}
# Autoroute files
# GITIGNORE+=( ${BASE}.bin ${BASE}.dsn ${BASE}.ses )
GITIGNORE+=( ${BASE}.bin ${BASE}.dsn ${BASE}.ses )
# Other stuff
GITIGNORE+=( ${BASE}-rescue.lib )
fi
......@@ -78,6 +73,7 @@ for a in "${GITATTRIBUTES[@]}" ; do
echo "${a}" >> .gitattributes
fi
done
FILTER=( "filter.kicad-pro.clean ~/.config/git/kicad-pro-filter clean %f" )
FILTER+=( "filter.kicad-pro.smudge ~/.config/git/kicad-pro-filter smudge %f" )
FILTER+=( "filter.kicad-sch.clean ~/.config/git/kicad-sch-filter clean %f" )
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment