GIT source control using saveflow from node-red-contrib-flowman

This flow is a very simplistic example of use of saveflow with git on the server (with NR running as the right user....). you will need to install https://www.npmjs.com/package/node-red-contrib-flowman to use this flow.

It uses a 'form' ui element to allow a commit message to be entered and submitted, saves ALL flows, and then runs a script to commit.

Change '/home/simon/flows/admin' in the save node and '/home/simon/flows/commit.sh' in the exec node and '/home/simon/flows' in the commit.sh to your liking.

I use this in combination with SourceTree to pull the git repo over ssh from my linux server into my 'main' repos on my windows machine, so that I don't ever have to login to the server in order to manage the 'source'.

So basically, now I can hack about my flows, and with each major change, commit them to git, and with the .js files being tracked outside of the flows, I can see exactly what I changed and when, and revert changes I don;t want manually in the NR editor.

The script 'commit.sh' is:

#!/bin/sh
cd /home/simon/flows
git add .
git commit -m "$1"
[{"id":"7862bfea.02df6","type":"saveflow","z":"1187c682.1d63f9","name":"SaveFlows","path":"/home/simon/flows/admin/","enabled":false,"x":390,"y":100,"wires":[["63ce25cf.7dbf8c"]]},{"id":"fbe63e29.a013a","type":"inject","z":"1187c682.1d63f9","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":120,"y":40,"wires":[["d8d29c7a.46966"]]},{"id":"d8d29c7a.46966","type":"function","z":"1187c682.1d63f9","name":"doall","func":"if (msg.payload.commitmsg){\n    msg.commitmsg = msg.payload.commitmsg;\n}\n\nmsg.flowId = 'all';\n\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":100,"wires":[["7862bfea.02df6"]]},{"id":"2dd6138d.009e8c","type":"exec","z":"1187c682.1d63f9","command":"/home/simon/flows/commit.sh","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"git-commit","x":630,"y":140,"wires":[["2f4a0d86.55f5a2"],["d6379e8b.32c67"],[]]},{"id":"63ce25cf.7dbf8c","type":"function","z":"1187c682.1d63f9","name":"set-commit-message","func":"if (msg.commitmsg){\n    msg.payload = '\\\"' + msg.commitmsg + '\\\"';\n} else {\n    msg.payload = '\\\"auto commit ' + (new Date()) + '\\\"';\n}\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":140,"wires":[["2dd6138d.009e8c"]]},{"id":"2f4a0d86.55f5a2","type":"ui_text","z":"1187c682.1d63f9","group":"c856d016.1beee","order":2,"width":"6","height":"4","name":"","label":"Stdout Result:","format":"{{msg.payload}}","layout":"col-center","x":800,"y":100,"wires":[]},{"id":"d6379e8b.32c67","type":"ui_text","z":"1187c682.1d63f9","group":"c856d016.1beee","order":3,"width":"6","height":"4","name":"","label":"Stderr Result:","format":"{{msg.payload}}","layout":"col-center","x":800,"y":140,"wires":[]},{"id":"c62fef78.f3454","type":"ui_form","z":"1187c682.1d63f9","name":"","label":"","group":"c856d016.1beee","order":1,"width":"6","height":"2","options":[{"label":"Commit Message","value":"commitmsg","type":"text","required":true}],"formValue":{"commitmsg":""},"payload":"","topic":"","x":90,"y":100,"wires":[["d8d29c7a.46966"]]},{"id":"c856d016.1beee","type":"ui_group","z":"","name":"GIT","tab":"31d0ff31.88081","disp":true,"width":"6"},{"id":"31d0ff31.88081","type":"ui_tab","z":"","name":"GIT","icon":"dashboard"}]
btsimonh

Flow Info

created 2 weeks, 5 days ago

Node Types

Core
  • exec (x1)
  • function (x2)
  • inject (x1)
Other
  • saveflow (x1)
  • ui_form (x1)
  • ui_group (x1)
  • ui_tab (x1)
  • ui_text (x2)

Tags

  • git
  • flowman
  • save
  • source
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option