-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement basic sync and offline mode for github-mount mode #50
Comments
This needs to be a new js-git mixin that performs sync between arbitrary js-git instances. // options.localRef - local ref to sync
// options.remoteRef - remote ref to sync
// options.localDepth - Depth for shallow local clones
local.sync(remote, options, function (err, report) {
// report.sent - number of hashes sent
// report.received - number of hashes received
// report.ahead - number of commits we have ahead of remote
// report.behind - number of commits we have behind remote
// if ahead and behind are non-zero, then the repos have diverged
// if they haven't diverged then one side can fast-forward.
}); The algorithm needs to favor reading from the local repo, even when discovering what the remote has. Assume the remote is always a full (non shallow) repo with no dangling links. So, for example, if you want to push commit B (who's parent is A) and you know remote has A, you can scan the tree of local A to see what remote A would have. |
After we have this basic sync, we need basic merge. |
Example of "clone" using var local = {};
require('git-node-fs/mixins/fs-db')(local, "path/to/repo.git");
require('js-git/mixins/sync')(local);
var remote = {};
require('js-github/mixins/github-db')(remote, "creationix/js-git", githubToken);
// Assume we're running in a gen-run block with generators
var localRef = "refs/heads/master";
var remoteRef = "refs/heads/master";
var report = yield local.sync(remote, {
localRef: localRef,
remoteRef: remoteRef,
localDepth: 1
});
if (report.ahead) {
if (report.behind) {
throw "TODO: Implement merge"
}
// Fast-forward the remote master to match local's master
yield remote.updateRef(remoteRef, yield local.readRef(localRef));
}
else {
if (report.behind) {
// Fast-forward the local master to match the remote's master
yield local.updateRef(localRef, yield remote.readRef(remoteRef));
}
} |
No description provided.
The text was updated successfully, but these errors were encountered: