mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
Issue #130 -- hangs after pull uncaught result
This commit is contained in:
parent
97bcd2bb31
commit
73660f7126
7 changed files with 116 additions and 16 deletions
|
@ -18,6 +18,13 @@ var EventBaton = require('../util/eventBaton').EventBaton;
|
|||
|
||||
var ORIGIN_PREFIX = 'o/';
|
||||
var TAB = ' ';
|
||||
var SHORT_CIRCUIT_CHAIN = 'STAPH';
|
||||
|
||||
function catchShortCircuit(err) {
|
||||
if (err !== SHORT_CIRCUIT_CHAIN) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
function GitEngine(options) {
|
||||
this.rootCommit = null;
|
||||
|
@ -965,16 +972,19 @@ GitEngine.prototype.fetch = function(options) {
|
|||
// then we get the difference in commits between these two graphs
|
||||
var commitsToMake = [];
|
||||
_.each(branchesToFetch, function(localRemoteBranch) {
|
||||
options.dontThrowOnNoFetch = true;
|
||||
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
||||
this,
|
||||
this.origin,
|
||||
localRemoteBranch,
|
||||
this.origin.refs[localRemoteBranch.getBaseID()],
|
||||
options
|
||||
_.extend(
|
||||
{},
|
||||
options,
|
||||
{dontThrowOnNoFetch: true}
|
||||
)
|
||||
));
|
||||
}, this);
|
||||
if (!commitsToMake.length) {
|
||||
if (!commitsToMake.length && !options.dontThrowOnNoFetch) {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-origin-fetch-uptodate')
|
||||
});
|
||||
|
@ -1124,6 +1134,20 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
|||
var chain = pendingFetch.chain;
|
||||
var deferred = pendingFetch.deferred;
|
||||
|
||||
// TODO -- hax hax. need to loop all branches
|
||||
// first lets check if we even need to merge (TODO -- expand this)
|
||||
var currentLocation = 'master';
|
||||
var targetSource = 'o/master';
|
||||
|
||||
chain = chain.then(_.bind(function() {
|
||||
if (this.mergeCheck(targetSource, currentLocation)) {
|
||||
this.command.set('error', new CommandResult({
|
||||
msg: intl.str('git-result-uptodate')
|
||||
}));
|
||||
throw SHORT_CIRCUIT_CHAIN;
|
||||
}
|
||||
}, this));
|
||||
|
||||
// delay a bit after the intense refresh animation from
|
||||
// fetch
|
||||
chain = chain.then(_.bind(function() {
|
||||
|
@ -1163,6 +1187,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
|||
this.gitVisuals
|
||||
);
|
||||
}, this));
|
||||
chain = chain.fail(catchShortCircuit);
|
||||
|
||||
this.animationQueue.thenFinish(chain, deferred);
|
||||
};
|
||||
|
@ -1971,12 +1996,17 @@ GitEngine.prototype.rebaseFinish = function(
|
|||
return chain;
|
||||
};
|
||||
|
||||
GitEngine.prototype.mergeCheck = function(targetSource, currentLocation) {
|
||||
var sameCommit = this.getCommitFromRef(targetSource) ===
|
||||
this.getCommitFromRef(currentLocation);
|
||||
return this.isUpstreamOf(targetSource, currentLocation) || sameCommit;
|
||||
};
|
||||
|
||||
GitEngine.prototype.merge = function(targetSource) {
|
||||
var currentLocation = 'HEAD';
|
||||
|
||||
// first some conditions
|
||||
if (this.isUpstreamOf(targetSource, currentLocation) ||
|
||||
this.getCommitFromRef(targetSource) === this.getCommitFromRef(currentLocation)) {
|
||||
if (this.mergeCheck(targetSource, currentLocation)) {
|
||||
throw new CommandResult({
|
||||
msg: intl.str('git-result-uptodate')
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue