Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kicad-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
kicad-utils
Commits
f733e69f
Commit
f733e69f
authored
7 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Changed filters for .pro and .sch
parent
5e60638e
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
kicad-git-setup
+33
-7
33 additions, 7 deletions
kicad-git-setup
kicad-pro-filter
+52
-0
52 additions, 0 deletions
kicad-pro-filter
kicad-sch-filter
+69
-0
69 additions, 0 deletions
kicad-sch-filter
with
155 additions
and
7 deletions
.gitignore
0 → 100644
+
1
−
0
View file @
f733e69f
*~
This diff is collapsed.
Click to expand it.
kicad-git-setup
+
33
−
7
View file @
f733e69f
#!/bin/sh
#!/bin/
ba
sh
shopt
-s
nullglob
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
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
done
SCHEMATICS
=(
*
.sch
)
SCHEMATICS
=(
*
.sch
)
if
[
${#
SCHEMATICS
[*]
}
-eq
0
]
;
then
if
[
${#
SCHEMATICS
[*]
}
-eq
0
]
;
then
echo
"No schematic file(s) in directory"
>
&2
echo
"No schematic file(s) in directory"
>
&2
...
@@ -35,8 +60,9 @@ for i in "${GITIGNORE[@]}" ; do
...
@@ -35,8 +60,9 @@ for i in "${GITIGNORE[@]}" ; do
done
done
# Install filtering (see https://jnavila.github.io/plotkicadsch/)
# Install filtering (see https://jnavila.github.io/plotkicadsch/)
GITATTRIBUTES
=(
"*.pro filter=kicad_pro"
)
GITATTRIBUTES+
=(
"*.pro filter=kicad-pro"
)
GITATTRIBUTES+
=(
"*.sch filter=kicad_sch"
)
GITATTRIBUTES+
=(
"*.sch ident"
)
GITATTRIBUTES+
=(
"*.sch filter=kicad-sch"
)
if
[
!
-f
.gitattributes
]
;
then
if
[
!
-f
.gitattributes
]
;
then
touch
.gitattributes
touch
.gitattributes
fi
fi
...
@@ -45,10 +71,10 @@ for a in "${GITATTRIBUTES[@]}" ; do
...
@@ -45,10 +71,10 @@ for a in "${GITATTRIBUTES[@]}" ; do
echo
"
${
a
}
"
>>
.gitattributes
echo
"
${
a
}
"
>>
.gitattributes
fi
fi
done
done
FILTER
=(
"filter.kicad
_
pro.clean
sed -E 's/^update=.*
$/
update=Date/'
"
)
FILTER
=(
"filter.kicad
-
pro.clean
~/.config/git/kicad-pro-filter clean %f
"
)
FILTER+
=(
"filter.kicad
_
pro.smudge
cat
"
)
FILTER+
=(
"filter.kicad
-
pro.smudge
~/.config/git/kicad-pro-filter smudge %f
"
)
FILTER+
=(
"filter.kicad
_
sch.clean
sed -E 's/#(PWR|FLG)[0-9]+/#
\1
?/'
"
)
FILTER+
=(
"filter.kicad
-
sch.clean
~/.config/git/kicad-sch-filter clean %f
"
)
FILTER+
=(
"filter.kicad
_
sch.smudge
cata
"
)
FILTER+
=(
"filter.kicad
-
sch.smudge
~/.config/git/kicad-sch-filter smudge %f
"
)
for
f
in
"
${
FILTER
[@]
}
"
;
do
for
f
in
"
${
FILTER
[@]
}
"
;
do
if
[[
"
$f
"
=
~
([
^
\
]
+
)[
\
]
+
(
.
*
)
]]
;
then
if
[[
"
$f
"
=
~
([
^
\
]
+
)[
\
]
+
(
.
*
)
]]
;
then
KEY
=
${
BASH_REMATCH
[1]
}
KEY
=
${
BASH_REMATCH
[1]
}
...
...
This diff is collapsed.
Click to expand it.
kicad-pro-filter
0 → 100755
+
52
−
0
View file @
f733e69f
#!/usr/bin/python3
import
sys
import
re
def
clean
(
filename
):
for
line
in
sys
.
stdin
:
line
=
line
[
0
:
-
1
]
m
=
re
.
match
(
'
^#\$Id[^\$]*\$$
'
,
line
)
if
m
:
continue
m
=
re
.
match
(
'
^(update|last_client)=
'
,
line
)
if
m
:
print
(
"
%s=
"
%
m
.
group
(
1
))
continue
m
=
re
.
match
(
'
^\[([^\]]*)\]
'
,
line
)
if
m
:
key
=
m
.
group
(
1
)
break
print
(
line
)
section
=
{}
section
[
key
]
=
[]
for
line
in
sys
.
stdin
:
line
=
line
[
0
:
-
1
]
m
=
re
.
match
(
'
^\[([^\]]*)\]
'
,
line
)
if
m
:
key
=
m
.
group
(
1
)
section
[
key
]
=
[]
continue
section
[
key
].
append
(
line
)
for
k
in
sorted
(
section
.
keys
()):
print
(
'
[%s]
'
%
k
)
for
line
in
section
[
k
]:
print
(
line
)
def
smudge
(
filename
):
for
line
in
sys
.
stdin
:
line
=
line
[
0
:
-
1
]
m
=
re
.
match
(
'
^#\$Id[^\$]*\$$
'
,
line
)
if
m
:
continue
print
(
line
)
if
__name__
==
'
__main__
'
:
if
sys
.
argv
[
1
]
==
'
clean
'
:
clean
(
sys
.
argv
[
2
])
elif
sys
.
argv
[
1
]
==
'
smudge
'
:
smudge
(
sys
.
argv
[
2
])
else
:
raise
Exception
(
"
Unknown command
'
%s
'
on
'
%s
'"
,
sys
.
argv
[
1
],
sys
.
argv
[
2
])
This diff is collapsed.
Click to expand it.
kicad-sch-filter
0 → 100755
+
69
−
0
View file @
f733e69f
#!/bin/bash
clean
()
{
IFS
=
read
-r
LINE
if
[[
"
${
LINE
}
"
=
~ ^
(
EESchema.
*
[
^
\
])[
\
]
*
\#
(
\$
Id.
*
\$
)
$
]]
;
then
echo
"
${
BASH_REMATCH
[1]
}
#
${
BASH_REMATCH
[2]
}
"
elif
[[
"
${
LINE
}
"
=
~ ^
(
EESchema[^
\#\$
]
*
[
^
\
])[
\
]
*
$
]]
;
then
echo
"
${
BASH_REMATCH
[1]
}
#
\$
Id
\$
"
else
echo
"Unknown schema type '
${
LINE
}
'"
1>&2
exit
1
fi
(
while
IFS
=
read
-r
LINE
;
do
if
[[
"
${
LINE
}
"
=
~ ^
((
Rev|Date
)
\ \"
)
.
*
(
\"
)
]]
;
then
# Clean out revision and date
echo
"
${
BASH_REMATCH
[1]
}${
BASH_REMATCH
[3]
}
"
else
echo
"
${
LINE
}
"
fi
done
)
|
sed
-E
's/#(PWR|FLG)[0-9]+/#\1?/'
}
smudge
()
{
local
REV
=
"Unknown"
local
DATE
=
"Unknown"
local
HASH
=
IFS
=
read
-r
LINE
if
[[
"
${
LINE
}
"
=
~ ^EESchema.
*
\#\$
Id:
(
.
*
)
\$
]]
;
then
local
HASH
=
${
BASH_REMATCH
[1]
}
REV
=
$(
git describe
${
HASH
}
2>/dev/null |
sed
-e
's/:.*//'
)
if
[
-z
"
${
REV
}
"
]
;
then
REV
=
"g
$(
git describe
--always
${
HASH
}
|
sed
-e
's/:.*//'
)
"
fi
DATE
=
$(
git log
--format
=
"%ai"
--
"
$1
"
|
head
-1
)
if
[
-z
"
${
DATE
}
"
]
;
then
DATE
=
"Unknown2"
fi
echo
"
${
LINE
}
"
elif
[[
"
${
LINE
}
"
=
~ ^EESchema.
*
]]
;
then
echo
"
${
LINE
}
"
else
echo
"Unknown schema type '
${
LINE
}
'"
1>&2
exit
1
fi
while
IFS
=
read
-r
LINE
;
do
if
[[
"
${
LINE
}
"
=
~ ^
(
Rev
\ \"
)
.
*
(
\"
)
]]
;
then
echo
"
${
BASH_REMATCH
[1]
}${
REV
}${
BASH_REMATCH
[2]
}
"
elif
[[
"
${
LINE
}
"
=
~ ^
(
Date
\ \"
)
.
*
(
\"
)
]]
;
then
echo
"
${
BASH_REMATCH
[1]
}${
DATE
}${
BASH_REMATCH
[2]
}
"
else
echo
"
${
LINE
}
"
fi
done
}
case
"
$1
"
in
clean
)
clean
$2
;;
smudge
)
smudge
$2
;;
*
)
echo
"unknown command '
$1
'"
1>&2
;;
esac
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment