Giter VIP home page Giter VIP logo

verbose-octo-chainsaw's Introduction

verbose-octo-chainsaw

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.)

BASIC DESIGN

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).

SETUP AND USAGE

SERVER

  • 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

CLIENT

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.

CLIENT SCRIPTS

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 via OCTO_CHAINSAW_DIR
  • OCTO_CHAINSAW_ORIGIN : If your .git/config contains more than one origin definitions you can pass in the one to use via OCTO_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.
getChanges

Fetches origin/main and attempts to merge it into the current branch.

pushChanges

Detects all locally changed files and commits them to the git tree. Push the current branch to origin when needed.

sync

Runs pushChanges and getChanges. Handles notification for all error cases.

TODO document notification possibilities

ANDROID

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.

FAQ

Has the name been autogenerated by github?

Yes.

TODOs

  • switch from origin/master to origin/main

verbose-octo-chainsaw's People

Contributors

agschaid avatar

Watchers

 avatar  avatar  avatar

verbose-octo-chainsaw's Issues

Files with Umlauts are apparently ignored

the script is apparently not picking up Files that contain Umlauts (ä,ö,ü) in their name.

(I am allowed to give such a bad bug report, since I am the maintainer)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.