mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-09 22:24:26 +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
|
@ -125,4 +125,5 @@ Or reported an issue that was successfully closed!
|
||||||
* Nicholas "LB" Braden
|
* Nicholas "LB" Braden
|
||||||
* Jeffrey Jones
|
* Jeffrey Jones
|
||||||
* Kyle (kyleIDMI)
|
* Kyle (kyleIDMI)
|
||||||
|
* "iplus"
|
||||||
|
|
||||||
|
|
|
@ -7244,6 +7244,13 @@ var EventBaton = require('../util/eventBaton').EventBaton;
|
||||||
|
|
||||||
var ORIGIN_PREFIX = 'o/';
|
var ORIGIN_PREFIX = 'o/';
|
||||||
var TAB = ' ';
|
var TAB = ' ';
|
||||||
|
var SHORT_CIRCUIT_CHAIN = 'STAPH';
|
||||||
|
|
||||||
|
function catchShortCircuit(err) {
|
||||||
|
if (err !== SHORT_CIRCUIT_CHAIN) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function GitEngine(options) {
|
function GitEngine(options) {
|
||||||
this.rootCommit = null;
|
this.rootCommit = null;
|
||||||
|
@ -8191,16 +8198,19 @@ GitEngine.prototype.fetch = function(options) {
|
||||||
// then we get the difference in commits between these two graphs
|
// then we get the difference in commits between these two graphs
|
||||||
var commitsToMake = [];
|
var commitsToMake = [];
|
||||||
_.each(branchesToFetch, function(localRemoteBranch) {
|
_.each(branchesToFetch, function(localRemoteBranch) {
|
||||||
options.dontThrowOnNoFetch = true;
|
|
||||||
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
||||||
this,
|
this,
|
||||||
this.origin,
|
this.origin,
|
||||||
localRemoteBranch,
|
localRemoteBranch,
|
||||||
this.origin.refs[localRemoteBranch.getBaseID()],
|
this.origin.refs[localRemoteBranch.getBaseID()],
|
||||||
options
|
_.extend(
|
||||||
|
{},
|
||||||
|
options,
|
||||||
|
{dontThrowOnNoFetch: true}
|
||||||
|
)
|
||||||
));
|
));
|
||||||
}, this);
|
}, this);
|
||||||
if (!commitsToMake.length) {
|
if (!commitsToMake.length && !options.dontThrowOnNoFetch) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: intl.str('git-error-origin-fetch-uptodate')
|
msg: intl.str('git-error-origin-fetch-uptodate')
|
||||||
});
|
});
|
||||||
|
@ -8350,6 +8360,20 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
||||||
var chain = pendingFetch.chain;
|
var chain = pendingFetch.chain;
|
||||||
var deferred = pendingFetch.deferred;
|
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
|
// delay a bit after the intense refresh animation from
|
||||||
// fetch
|
// fetch
|
||||||
chain = chain.then(_.bind(function() {
|
chain = chain.then(_.bind(function() {
|
||||||
|
@ -8389,6 +8413,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
}, this));
|
}, this));
|
||||||
|
chain = chain.fail(catchShortCircuit);
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
};
|
};
|
||||||
|
@ -9197,12 +9222,17 @@ GitEngine.prototype.rebaseFinish = function(
|
||||||
return chain;
|
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) {
|
GitEngine.prototype.merge = function(targetSource) {
|
||||||
var currentLocation = 'HEAD';
|
var currentLocation = 'HEAD';
|
||||||
|
|
||||||
// first some conditions
|
// first some conditions
|
||||||
if (this.isUpstreamOf(targetSource, currentLocation) ||
|
if (this.mergeCheck(targetSource, currentLocation)) {
|
||||||
this.getCommitFromRef(targetSource) === this.getCommitFromRef(currentLocation)) {
|
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: intl.str('git-result-uptodate')
|
msg: intl.str('git-result-uptodate')
|
||||||
});
|
});
|
||||||
|
@ -26061,6 +26091,13 @@ var EventBaton = require('../util/eventBaton').EventBaton;
|
||||||
|
|
||||||
var ORIGIN_PREFIX = 'o/';
|
var ORIGIN_PREFIX = 'o/';
|
||||||
var TAB = ' ';
|
var TAB = ' ';
|
||||||
|
var SHORT_CIRCUIT_CHAIN = 'STAPH';
|
||||||
|
|
||||||
|
function catchShortCircuit(err) {
|
||||||
|
if (err !== SHORT_CIRCUIT_CHAIN) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function GitEngine(options) {
|
function GitEngine(options) {
|
||||||
this.rootCommit = null;
|
this.rootCommit = null;
|
||||||
|
@ -27008,16 +27045,19 @@ GitEngine.prototype.fetch = function(options) {
|
||||||
// then we get the difference in commits between these two graphs
|
// then we get the difference in commits between these two graphs
|
||||||
var commitsToMake = [];
|
var commitsToMake = [];
|
||||||
_.each(branchesToFetch, function(localRemoteBranch) {
|
_.each(branchesToFetch, function(localRemoteBranch) {
|
||||||
options.dontThrowOnNoFetch = true;
|
|
||||||
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
||||||
this,
|
this,
|
||||||
this.origin,
|
this.origin,
|
||||||
localRemoteBranch,
|
localRemoteBranch,
|
||||||
this.origin.refs[localRemoteBranch.getBaseID()],
|
this.origin.refs[localRemoteBranch.getBaseID()],
|
||||||
options
|
_.extend(
|
||||||
|
{},
|
||||||
|
options,
|
||||||
|
{dontThrowOnNoFetch: true}
|
||||||
|
)
|
||||||
));
|
));
|
||||||
}, this);
|
}, this);
|
||||||
if (!commitsToMake.length) {
|
if (!commitsToMake.length && !options.dontThrowOnNoFetch) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: intl.str('git-error-origin-fetch-uptodate')
|
msg: intl.str('git-error-origin-fetch-uptodate')
|
||||||
});
|
});
|
||||||
|
@ -27167,6 +27207,20 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
||||||
var chain = pendingFetch.chain;
|
var chain = pendingFetch.chain;
|
||||||
var deferred = pendingFetch.deferred;
|
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
|
// delay a bit after the intense refresh animation from
|
||||||
// fetch
|
// fetch
|
||||||
chain = chain.then(_.bind(function() {
|
chain = chain.then(_.bind(function() {
|
||||||
|
@ -27206,6 +27260,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
}, this));
|
}, this));
|
||||||
|
chain = chain.fail(catchShortCircuit);
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
};
|
};
|
||||||
|
@ -28014,12 +28069,17 @@ GitEngine.prototype.rebaseFinish = function(
|
||||||
return chain;
|
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) {
|
GitEngine.prototype.merge = function(targetSource) {
|
||||||
var currentLocation = 'HEAD';
|
var currentLocation = 'HEAD';
|
||||||
|
|
||||||
// first some conditions
|
// first some conditions
|
||||||
if (this.isUpstreamOf(targetSource, currentLocation) ||
|
if (this.mergeCheck(targetSource, currentLocation)) {
|
||||||
this.getCommitFromRef(targetSource) === this.getCommitFromRef(currentLocation)) {
|
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: intl.str('git-result-uptodate')
|
msg: intl.str('git-result-uptodate')
|
||||||
});
|
});
|
||||||
|
|
1
build/bundle.min.66308339.js
Normal file
1
build/bundle.min.66308339.js
Normal file
File diff suppressed because one or more lines are too long
1
build/bundle.min.js
vendored
Normal file
1
build/bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -445,7 +445,7 @@
|
||||||
For a much easier time perusing the source, see the individual files at:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
-->
|
-->
|
||||||
<script src="build/bundle.js"></script>
|
<script src="build/bundle.min.66308339.js"></script>
|
||||||
|
|
||||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
||||||
The downside? No raw logs to parse for analytics, so I have to include
|
The downside? No raw logs to parse for analytics, so I have to include
|
||||||
|
|
|
@ -78,5 +78,12 @@ describe('Git Remotes', function() {
|
||||||
'{"branches":{"master":{"target":"C1","id":"master"},"bugFix":{"target":"C1","id":"bugFix"},"o/master":{"target":"C2","id":"o/master"},"o/bugFix":{"target":"C1","id":"o/bugFix"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master"},"bugFix":{"target":"C1","id":"bugFix"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
'{"branches":{"master":{"target":"C1","id":"master"},"bugFix":{"target":"C1","id":"bugFix"},"o/master":{"target":"C2","id":"o/master"},"o/bugFix":{"target":"C1","id":"o/bugFix"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master"},"bugFix":{"target":"C1","id":"bugFix"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('pulls with nothing and then commits', function() {
|
||||||
|
expectTreeAsync(
|
||||||
|
'git clone; git pull; git commit',
|
||||||
|
'{"branches":{"master":{"target":"C2","id":"master"},"o/master":{"target":"C1","id":"o/master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,13 @@ var EventBaton = require('../util/eventBaton').EventBaton;
|
||||||
|
|
||||||
var ORIGIN_PREFIX = 'o/';
|
var ORIGIN_PREFIX = 'o/';
|
||||||
var TAB = ' ';
|
var TAB = ' ';
|
||||||
|
var SHORT_CIRCUIT_CHAIN = 'STAPH';
|
||||||
|
|
||||||
|
function catchShortCircuit(err) {
|
||||||
|
if (err !== SHORT_CIRCUIT_CHAIN) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function GitEngine(options) {
|
function GitEngine(options) {
|
||||||
this.rootCommit = null;
|
this.rootCommit = null;
|
||||||
|
@ -965,16 +972,19 @@ GitEngine.prototype.fetch = function(options) {
|
||||||
// then we get the difference in commits between these two graphs
|
// then we get the difference in commits between these two graphs
|
||||||
var commitsToMake = [];
|
var commitsToMake = [];
|
||||||
_.each(branchesToFetch, function(localRemoteBranch) {
|
_.each(branchesToFetch, function(localRemoteBranch) {
|
||||||
options.dontThrowOnNoFetch = true;
|
|
||||||
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
||||||
this,
|
this,
|
||||||
this.origin,
|
this.origin,
|
||||||
localRemoteBranch,
|
localRemoteBranch,
|
||||||
this.origin.refs[localRemoteBranch.getBaseID()],
|
this.origin.refs[localRemoteBranch.getBaseID()],
|
||||||
options
|
_.extend(
|
||||||
|
{},
|
||||||
|
options,
|
||||||
|
{dontThrowOnNoFetch: true}
|
||||||
|
)
|
||||||
));
|
));
|
||||||
}, this);
|
}, this);
|
||||||
if (!commitsToMake.length) {
|
if (!commitsToMake.length && !options.dontThrowOnNoFetch) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: intl.str('git-error-origin-fetch-uptodate')
|
msg: intl.str('git-error-origin-fetch-uptodate')
|
||||||
});
|
});
|
||||||
|
@ -1124,6 +1134,20 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
||||||
var chain = pendingFetch.chain;
|
var chain = pendingFetch.chain;
|
||||||
var deferred = pendingFetch.deferred;
|
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
|
// delay a bit after the intense refresh animation from
|
||||||
// fetch
|
// fetch
|
||||||
chain = chain.then(_.bind(function() {
|
chain = chain.then(_.bind(function() {
|
||||||
|
@ -1163,6 +1187,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
|
||||||
this.gitVisuals
|
this.gitVisuals
|
||||||
);
|
);
|
||||||
}, this));
|
}, this));
|
||||||
|
chain = chain.fail(catchShortCircuit);
|
||||||
|
|
||||||
this.animationQueue.thenFinish(chain, deferred);
|
this.animationQueue.thenFinish(chain, deferred);
|
||||||
};
|
};
|
||||||
|
@ -1971,12 +1996,17 @@ GitEngine.prototype.rebaseFinish = function(
|
||||||
return chain;
|
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) {
|
GitEngine.prototype.merge = function(targetSource) {
|
||||||
var currentLocation = 'HEAD';
|
var currentLocation = 'HEAD';
|
||||||
|
|
||||||
// first some conditions
|
// first some conditions
|
||||||
if (this.isUpstreamOf(targetSource, currentLocation) ||
|
if (this.mergeCheck(targetSource, currentLocation)) {
|
||||||
this.getCommitFromRef(targetSource) === this.getCommitFromRef(currentLocation)) {
|
|
||||||
throw new CommandResult({
|
throw new CommandResult({
|
||||||
msg: intl.str('git-result-uptodate')
|
msg: intl.str('git-result-uptodate')
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue