A little syncer setup for textfiles (notes, todo.txt,...) using git.
Might not work for you. Hell, it might not even work for me. I'll tell you when I know. (Update two years later: yes. It works for me.)
verbose-octo-chainsaw is meant to be run as one central (bare) git repo and one or multiple other repos (I call them client repos) automatically pushing their changes. Since this involves server-sides hooks you will need to have full control over your git-server (github and gitlab will not do).
Every client repo is meant to be opperated with their own unique branch being checked out. This branch is their "upstream" and will also be used when generating commit messages (so you have an idea where your changes cane from).
To client repos the master (TODO: switch to main) branch is the "downstream" where they can pull the consolidated changes of other repos. No client repo can push to this branch (one of the server hooks prevents it). When a client pushes its own branch to the remote the central repo will try to merge that branch into main (which updates the downstream for all repos).
git init --bare txt.git
- configure an email and a name for that repo. I, for one, use "[email protected]" and "txt server"
- Copy contents of serverhooks/ to txt.git/hooks/ and make them executable or just set a symbolic link to there
- you will probably want to add your clients public key to the git server so you can sync without having to log in
Basic Linux setup:
- clone this repo (in all examples I'll assume this to be cloned into
~/github/
) - clone your central txt repo
- cd into your client txt repo and checkout a branch a descriptive name (e.g. "Laptop" or "MobilePhone"). Remain on that branch.
- run
echo '.octo_chainsaw_lock' >> .gitignore
You're done. Now use the client scripts to update and sync your local repos.
All scripts under ./clientScripts
can be controlled by some ENV variables.
The two most important are:
OCTO_CHAINSAW_DIR
: by default verbose-octo-chainsaw assumes to be run from the root of your client txt repo. You can override this by passing in the actual root viaOCTO_CHAINSAW_DIR
OCTO_CHAINSAW_ORIGIN
: If your.git/config
contains more than one origin definitions you can pass in the one to use viaOCTO_CHAINSAW_ORIGIN
.
When a script encounters some specific errors during git operations the will leave a .octo_chainsaw_lock
at the root of your repo which contains an error code and exit with the same error code.
Known error codes are:
- 111: when some local files are in an unknown git-state. This might happen when manually resolving a merge conflict.
- 222: when an error occured merging
origin/master
into the current branch. Usually a merge conflict that needs to be resolved manually. - 333: when the central repos responed with some error during push. Usually a merge conflict that needs to be resolved locally before pushing again.
- 123: action was aborted due to a pre-existing
.octo_chainsaw_lock
file. The value in the file will remain unchanged.
Fetches origin/main
and attempts to merge it into the current branch.
Detects all locally changed files and commits them to the git tree. Push the current branch to origin when needed.
Runs pushChanges
and getChanges
. Handles notification for all error cases.
TODO document notification possibilities
To run verbose-octo-chainsaw on android you need to install termux.
Activate the cron service if you want to use cronjobs. Acquiring wake lock should not be mandatory. Be aware though, that one same devices termux is killed with the message "Process completed (signal 9) - press Enter" after some time (which keeps cronjobs from runnint). See this issue for details and a fix.
Install termux-api if you want to receive notifications.
Yes.
- switch from origin/master to origin/main