Following on the previous post you might also want to print Git Sha1 on the produced PCB itself. Before we start, one note on this issue. You cannot put the Git Sha of the content of our repository to committed Gerberfiles, since putting its there will alter the content of those files! So how to we treat this issue? For software the source files (which you can think of as KiCad's kicad_pcb and kicad_sch files) are under revision control but the built binaries/artifacts (e.g., hex files on an embedded system) are not. So the solution is to not have the Gerber files under revision; for example you might put all production data into a folder called folder "production_data_output", the add this line
gitignore production_data_output/*
to the file .gitignore
First thing to do in KiCad PCB, is to create the label, which is called "GIT-REV: 12345678" and place it on good spot. Here the top silkscreen is used, but any layer of choice is possible.
Now we will use a similar script as previously to git sha here instead of "12345678". Add a script:
#!/bin/sh
gitSha=$(git rev-parse --short=8 HEAD)
old="GIT-REV: .*\" (at "
new="GIT-REV: ${gitSha}\" (at "
command="s/${old}/${new}/g"
sed -i "$command" $1
Note that it is important that the label "GIT-REV: 12345678" match the script's text "GIT-REV: ", otherwise sed won't find it!
תגובות