Fast, one-to-many git working directory sync for uncommitted changes
This tool allows a someone to work on a client computer in a normal git workflow (commit sometimes, save often) to sync their local uncommitted working directory state with one or more servers, so that compiler and application services (i.e. the intensive part of a development environment) can be offloaded to more capable, shared, and potentially remote infrastructure.
- Client checks out git repo (if required)
- Client runs GitSyncServer on the desired infrastructure (if required)
- Client runs GitSync, and points it to the local git repo and the IP address of GitSyncServer
- Begins listening to
git-change
andfile-change
events (this watcher could be external to the service) - Runs
NewSession
to negotiate initial state - Binds the
git-change
event to theNewSession
handler - Binds the
file-change
event to theSyncState
handler
- Terminates any current sessions
- Gets the current list of git remotes
- Fetches a list of the last
N
git commit hashes - Makes a
NewSessionRequest
to the GitSyncServer (parsing the list of git remotes and commits) - GitSyncServer will respond with the latest commit hash that is currently has in common with the list sent from the client
- Creates a
Session
from the common commit hash - Calls
Session#BuildPatch
on the session object - Calls
Session#SendPatchDiff
to update GitSyncServer
- Calls
git diff --cached $COMMON_COMMIT_HASH
and stores the result (the current uncommitted working directory state) along with an id for this patch (random?) - Deletes all stored patches except the two most recent
- Calls
Session#BuildPatch
to build the next patch - Calls
Session#SendPatchDiff
to update GitSyncServer
- Checks if
Session
is currently storing 2 patches a. If 1 patch is stored, make aApplyPatch
request to GitSyncServer with the patch, its id, and the common commit hash b. If 2 patches are stored, continue - Gets a diff from the two most recent patches
- Makes an
ApplyPatchDiff
request to GitSyncServer with that diff, the patch ids of the two patches (parent, and next), and the common commit hash
- Check the remotes match
- Run
git fetch
- Respond with the most recent common commit hash
- Checkout the common commit hash (discarding uncommitted changes)
- Store the patch and its id as the current patch
- Checkout the common commit hash (discarding uncommitted changes)
- Check that the parent id from client matches the current patch id
- Apply the patch diff to the current patch to re-construct the next patch
- Call
ApplyPatch
with the next patch and its id