Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. # GitSync (Working Title)
  2.  
  3. Fast, one-to-many git working directory sync for uncommitted changes
  4.  
  5. ## What
  6.  
  7. This tool allows a someone to work on a client computer in a normal git workflow (commit sometimes,
  8. save often) to sync their local uncommitted working directory state with one or more servers, so
  9. that compiler and application services (i.e. the intensive part of a development environment) can
  10. be offloaded to more capable, shared, and potentially remote infrastructure.
  11.  
  12. ## How
  13.  
  14. 1. Client checks out git repo (if required)
  15. 2. Client runs GitSyncServer on the desired infrastructure (if required)
  16. 3. Client runs GitSync, and points it to the local git repo and the IP address of GitSyncServer
  17.  
  18. ### GitSync
  19.  
  20. 1. Begins listening to `git-change` and `file-change` events (this watcher could be external to the service)
  21. 2. Runs `NewSession` to negotiate initial state
  22. 3. Binds the `git-change` event to the `NewSession` handler
  23. 4. Binds the `file-change` event to the `SyncState` handler
  24.  
  25. #### `NewSession`
  26.  
  27. 0. Terminates any current sessions
  28. 1. Gets the current list of git remotes
  29. 2. Fetches a list of the last `N` git commit hashes
  30. 3. Makes a `NewSessionRequest` to the GitSyncServer (parsing the list of git remotes and commits)
  31. 4. GitSyncServer will respond with the latest commit hash that is currently has in common with the
  32. list sent from the client
  33. 5. Creates a `Session` from the common commit hash
  34. 6. Calls `Session#BuildPatch` on the session object
  35. 7. Calls `Session#SendPatchDiff` to update GitSyncServer
  36.  
  37. #### `Session#BuildPatch`
  38.  
  39. 1. Calls `git diff --cached $COMMON_COMMIT_HASH` and stores the result (the current uncommitted
  40. working directory state) along with an id for this patch (random?)
  41. 2. Deletes all stored patches except the two most recent
  42.  
  43. #### `SyncState`
  44.  
  45. 1. Calls `Session#BuildPatch` to build the next patch
  46. 2. Calls `Session#SendPatchDiff` to update GitSyncServer
  47.  
  48. #### `Session#SendPatchDiff`
  49.  
  50. 1. Checks if `Session` is currently storing 2 patches
  51. a. If 1 patch is stored, make a `ApplyPatch` request to GitSyncServer with the patch, its id,
  52. and the common commit hash
  53. b. If 2 patches are stored, continue
  54. 2. Gets a diff from the two most recent patches
  55. 3. Makes an `ApplyPatchDiff` request to GitSyncServer with that diff, the patch ids of the two
  56. patches (parent, and next), and the common commit hash
  57.  
  58. ### GitSyncServer
  59.  
  60. #### `NewSessionRequest`
  61.  
  62. 1. Check the remotes match
  63. 2. Run `git fetch`
  64. 3. Respond with the most recent common commit hash
  65.  
  66. #### `ApplyPatch`
  67.  
  68. 1. Checkout the common commit hash (discarding uncommitted changes)
  69. 2. Store the patch and its id as the current patch
  70.  
  71. #### `ApplyPatchDiff`
  72.  
  73. 1. Checkout the common commit hash (discarding uncommitted changes)
  74. 2. Check that the parent id from client matches the current patch id
  75. 3. Apply the patch diff to the current patch to re-construct the next patch
  76. 4. Call `ApplyPatch` with the next patch and its id
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement