/Chrono

A git time machine

Primary LanguageGoMIT LicenseMIT

Chrono

Chrono

A git time machine

GitHub GitHub go.mod Go version

Chrono is a tool that automatically commits in a temporary branch in your git repository every time an event occurs (events are customizable), So that you can always rollback to a specific point in time if anything goes wrong. You can squash merge all the temporary commits into one once you are done.

Disclaimer

This is still in early development stages, if you are going to use it or test it, please use caution. Use at your own risk, I am NOT responsible for any of your acts.

How to install

First, clone the repository using

git clone https://github.com/hazyuun/Chrono.git

Then cd into it

cd Chrono

And install using

go install .

Make sure you have go installed, if not, you can easily install it using your package manager

The binary will be installed into ~/go/bin/ by default, make sure it is in your PATH environment variable, if not, you can add it using

export PATH="$HOME/go/bin/:$PATH"

Note that this will add ~/go/bin/ to PATH just for the current terminal session, you can add that line to your ~/.profile for a permanent effect.

Now you can run the following command to check if it is installed correctly

chrono --help

Workflow

Create a chrono session

Create a new session using

$ chrono session create session_name

Important: Please note that this will create a branch from the current HEAD, so make sure it is currently in the commit where you want to create the chrono session.

You can create as many sessions as you want, to list existing sessions you can run the following command

$ chrono session list

Start a chrono session

Start a chrono session using

$ chrono session start session_name

from now on, chrono will be automatically committing changes to the session's specific branch whenever an event occurs, events are customizable using a chrono.yaml file (see below for details)

Important: Please note that after you stop running this command, you will still be in the session branch for convinience

Squash merge and delete the session

When done, you can merge (A squash merge is recommended) the chrono branch to your original branch (let's call it original_branch)

$ git checkout original_branch
$ git merge --squash chrono/session_name

Then if everything is as expected, you can commit the merge

$ git commit -m "Your commit message"

and delete the session

$ chrono session delete session_name

Config file

Put a file named chrono.yml in the root of your repository, here is an example config file

# Events when to automatically commit
events:
    # This triggers every amount of minutes
    - periodic:

        # Every 60 seconds
        period: 60

        # Commit those files
        files: ["src/", "file.txt"] 

    # This triggers every file save
    - save:

        # Those files will be committed once they're saved
        files: ["notes.txt"]
        
# Use files: ["."] if you want all files to be commited

If you want to exclude some files when using files: ["."], just use your regular .gitignore file

Contributions

Pull requests and issues are welcome !