mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 16:38:50 +02:00
another bug fix and colored nodes
This commit is contained in:
parent
bca3e1d537
commit
15817f9220
4 changed files with 108 additions and 67 deletions
24
src/git.js
24
src/git.js
|
@ -355,6 +355,17 @@ GitEngine.prototype.getUpstreamBranchSet = function() {
|
|||
// this is expensive!! so only call once in a while
|
||||
var commitToSet = {};
|
||||
|
||||
var inArray = function(arr, id) {
|
||||
var found = false;
|
||||
_.each(arr, function(wrapper) {
|
||||
if (wrapper.id == id) {
|
||||
found = true;
|
||||
}
|
||||
});
|
||||
|
||||
return found;
|
||||
};
|
||||
|
||||
var bfsSearch = function(commit) {
|
||||
var set = [];
|
||||
var pQueue = [commit];
|
||||
|
@ -373,7 +384,14 @@ GitEngine.prototype.getUpstreamBranchSet = function() {
|
|||
var set = bfsSearch(branch.get('target'));
|
||||
_.each(set, function(id) {
|
||||
commitToSet[id] = commitToSet[id] || [];
|
||||
commitToSet[id].push(branch.get('id'));
|
||||
|
||||
// only add it if it's not there, so hue blending is ok
|
||||
if (!inArray(commitToSet[id], branch.get('id'))) {
|
||||
commitToSet[id].push({
|
||||
obj: branch,
|
||||
id: branch.get('id')
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -684,7 +702,8 @@ GitEngine.prototype.mergeStarter = function() {
|
|||
|
||||
GitEngine.prototype.merge = function(targetSource, currentLocation) {
|
||||
// first some conditions
|
||||
if (this.isUpstreamOf(targetSource, currentLocation)) {
|
||||
if (this.isUpstreamOf(targetSource, currentLocation) ||
|
||||
this.getCommitFromRef(targetSource) === this.getCommitFromRef(currentLocation)) {
|
||||
throw new CommandResult({
|
||||
msg: 'Branch already up-to-date'
|
||||
});
|
||||
|
@ -980,6 +999,7 @@ GitEngine.prototype.isUpstreamOf = function(child, ancestor) {
|
|||
|
||||
GitEngine.prototype.getUpstreamSet = function(ancestor) {
|
||||
var commit = this.getCommitFromRef(ancestor);
|
||||
var ancestorID = commit.get('id');
|
||||
var queue = [commit];
|
||||
|
||||
var exploredSet = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue