-
Notifications
You must be signed in to change notification settings - Fork 5
Development Workflow
This page covers how to set up your development machine for contributing to ArfBotOS, specifically the git workflow for tracking CODESYS project changes in a readable way.
The CODESYS project is stored as Codesys/ArfBot.project. This file is a binary-like format that git cannot meaningfully diff. To solve this, the repository maintains a companion file Codesys/ArfBot.xml — a PLCopen XML export of the same project — which git can diff cleanly. A normalizer script strips volatile metadata (timestamps, internal checksums, GUIDs) so that only real code changes appear in the diff.
A pre-commit hook enforces that both files are always committed together, so the XML always reflects the state of the project.
- Git for Windows — git-scm.com/download/win
- Python 3.7+ — python.org/downloads (add to PATH during install)
- CODESYS V3.5 SP20 Patch 3 — see Installation for setup instructions
This only needs to be done once per development machine.
- Open a terminal and navigate to the
codesys-git-difffolder inside the repo:
cd ArfBotOS\codesys-git-diff
- Run the setup script:
setup_codesys_git_diff.bat
This will:
- Register the XML normalizer as a git diff driver in your global
~/.gitconfig - Activate the pre-commit hook that enforces
.projectand.xmlare committed together - Verify that git and Python are available on your PATH
Note: The normalizer script must stay at the path where you ran setup. If you move the repo, re-run the setup script.
- Open
Codesys/ArfBot.projectin CODESYS and make your changes. - Build the project to verify there are no errors (Build → Generate Code).
Before committing, export the PLCopen XML using the built-in CODESYS menu:
- From the menu bar, click Project → Export PLCopenXML...
- In the export dialog, click Select > to select all objects, then click OK
- In the file save dialog, navigate to the
Codesys/folder, confirm the filename isArfBot.xml, and click Save (overwriting the existing file)
Note: The XML is for readable diffs only — it is not a full backup. Always use the
.projectfile for reverting changes (see Reverting Changes below).
Stage and commit both files together:
git add Codesys/ArfBot.project Codesys/ArfBot.xml
git commit -m "your message here"If you try to commit ArfBot.project without ArfBot.xml, the pre-commit hook will block the commit and remind you to run the export script first:
✗ Commit blocked: Codesys/ArfBot.project is staged but Codesys/ArfBot.xml is not.
Steps to fix:
1. In CODESYS: Project → Export PLCopenXML... → OK
→ save as Codesys/ArfBot.xml
2. git add Codesys/ArfBot.xml
3. git commit
Once set up, git diff automatically shows clean, human-readable diffs of the PLC code:
git diff HEAD~1 HEAD -- Codesys/ArfBot.xmlChanges to variable declarations, ST code, task configuration, and data types all show as clear line-by-line diffs. Internal CODESYS metadata that changes on every save is automatically stripped.
To revert the CODESYS project to a previous commit, check out the .project file and reopen it in CODESYS:
git checkout <commit-hash> -- Codesys/ArfBot.projectThen open Codesys/ArfBot.project in CODESYS. The XML is not used for reverting — it is a diff artifact only.
If codesys_xml_normalize.py is updated (e.g. to strip new noise attributes), the git diff cache must be cleared so git re-processes existing files with the new script. Run this once from inside the repo:
git update-ref -d refs/notes/textconv/codesys-xml| File | Purpose |
|---|---|
Codesys/ArfBot.project |
CODESYS project — source of truth, use for reverting |
Codesys/ArfBot.xml |
PLCopen XML export — use for readable git diffs |
codesys-git-diff/codesys_xml_normalize.py |
Normalizer run by git before diffing |
codesys-git-diff/setup_codesys_git_diff.bat |
One-time machine setup script |
.githooks/pre-commit |
Enforces .project and .xml are committed together |
.gitattributes |
Tells git to use the normalizer for .xml files |