mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
branch deleting down
This commit is contained in:
parent
1fee32879c
commit
f353fa118d
4 changed files with 39 additions and 31 deletions
44
src/git.js
44
src/git.js
|
@ -11,8 +11,8 @@ function GitEngine(options) {
|
||||||
this.refs = {};
|
this.refs = {};
|
||||||
this.HEAD = null;
|
this.HEAD = null;
|
||||||
this.id_gen = 0;
|
this.id_gen = 0;
|
||||||
this.branches = options.branches;
|
this.branchCollection = options.branches;
|
||||||
this.collection = options.collection;
|
this.commitCollection = options.collection;
|
||||||
|
|
||||||
// global variable to keep track of the options given
|
// global variable to keep track of the options given
|
||||||
// along with the command call.
|
// along with the command call.
|
||||||
|
@ -27,7 +27,7 @@ function GitEngine(options) {
|
||||||
GitEngine.prototype.init = function() {
|
GitEngine.prototype.init = function() {
|
||||||
// make an initial commit and a master branch
|
// make an initial commit and a master branch
|
||||||
this.rootCommit = new Commit({rootCommit: true});
|
this.rootCommit = new Commit({rootCommit: true});
|
||||||
this.collection.add(this.rootCommit);
|
this.commitCollection.add(this.rootCommit);
|
||||||
|
|
||||||
this.refs[this.rootCommit.get('id')] = this.rootCommit;
|
this.refs[this.rootCommit.get('id')] = this.rootCommit;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ GitEngine.prototype.makeBranch = function(id, target) {
|
||||||
target: target,
|
target: target,
|
||||||
id: id
|
id: id
|
||||||
});
|
});
|
||||||
this.branches.add(branch);
|
this.branchCollection.add(branch);
|
||||||
this.refs[branch.get('id')] = branch;
|
this.refs[branch.get('id')] = branch;
|
||||||
return branch;
|
return branch;
|
||||||
};
|
};
|
||||||
|
@ -97,7 +97,7 @@ GitEngine.prototype.getHead = function() {
|
||||||
|
|
||||||
GitEngine.prototype.getBranches = function() {
|
GitEngine.prototype.getBranches = function() {
|
||||||
var toReturn = [];
|
var toReturn = [];
|
||||||
this.branches.each(function(branch) {
|
this.branchCollection.each(function(branch) {
|
||||||
toReturn.push({
|
toReturn.push({
|
||||||
id: branch.get('id'),
|
id: branch.get('id'),
|
||||||
selected: this.HEAD.get('target') === branch,
|
selected: this.HEAD.get('target') === branch,
|
||||||
|
@ -132,7 +132,7 @@ GitEngine.prototype.makeCommit = function(parents, id) {
|
||||||
id: id
|
id: id
|
||||||
});
|
});
|
||||||
this.refs[commit.get('id')] = commit;
|
this.refs[commit.get('id')] = commit;
|
||||||
this.collection.add(commit);
|
this.commitCollection.add(commit);
|
||||||
return commit;
|
return commit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ GitEngine.prototype.getUpstreamBranchSet = function() {
|
||||||
return set;
|
return set;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.branches.each(function(branch) {
|
this.branchCollection.each(function(branch) {
|
||||||
var set = bfsSearch(branch.get('target'));
|
var set = bfsSearch(branch.get('target'));
|
||||||
_.each(set, function(id) {
|
_.each(set, function(id) {
|
||||||
commitToSet[id] = commitToSet[id] || [];
|
commitToSet[id] = commitToSet[id] || [];
|
||||||
|
@ -779,16 +779,16 @@ GitEngine.prototype.checkout = function(idOrTarget) {
|
||||||
GitEngine.prototype.branchStarter = function() {
|
GitEngine.prototype.branchStarter = function() {
|
||||||
// handle deletion first
|
// handle deletion first
|
||||||
if (this.commandOptions['-d'] || this.commandOptions['-D']) {
|
if (this.commandOptions['-d'] || this.commandOptions['-D']) {
|
||||||
var names = this.commandOptions['-d'];
|
var names = this.commandOptions['-d'] || this.commandOptions['-D'];
|
||||||
names = names.concat(this.commandOptions['-D']);
|
|
||||||
if (!names.length) {
|
if (!names.length) {
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: 'I expect branch names when deleting'
|
msg: 'I expect branch names when deleting'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_.each(names, _.bind(function(name) {
|
_.each(names, function(name) {
|
||||||
this.deleteBranch(name);
|
this.deleteBranch(name);
|
||||||
}, this));
|
}, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,20 +837,16 @@ GitEngine.prototype.deleteBranch = function(name) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = target.get('id');
|
// now we know it's a branch
|
||||||
target.delete();
|
var branch = target;
|
||||||
delete this.refs[id];
|
|
||||||
// delete from array
|
this.branchCollection.remove(branch);
|
||||||
// TODO
|
this.refs[branch.get('id')] = undefined;
|
||||||
var toDelete = -1;
|
delete this.refs[branch.get('id')];
|
||||||
_.each(this.branches, function(branch, index) {
|
|
||||||
console.log(branch);
|
if (branch.get('visBranch')) {
|
||||||
console.log(id);
|
branch.get('visBranch').remove();
|
||||||
if (branch.get('id') == id) {
|
|
||||||
toDelete = index;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
this.branches.splice(toDelete, 1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.unescapeQuotes = function(str) {
|
GitEngine.prototype.unescapeQuotes = function(str) {
|
||||||
|
|
12
src/tree.js
12
src/tree.js
|
@ -253,6 +253,18 @@ var VisBranch = Backbone.Model.extend({
|
||||||
return gitVisuals.blendHuesFromBranchStack(this.getBranchStackArray());
|
return gitVisuals.blendHuesFromBranchStack(this.getBranchStackArray());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
remove: function() {
|
||||||
|
var keys = ['text', 'arrow', 'rect'];
|
||||||
|
_.each(keys, function(key) {
|
||||||
|
if (this.get(key)) {
|
||||||
|
this.get(key).remove();
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
// also need to remove from gitVisuals
|
||||||
|
gitVisuals.removeVisBranch(this);
|
||||||
|
},
|
||||||
|
|
||||||
genGraphics: function(paper) {
|
genGraphics: function(paper) {
|
||||||
var textPos = this.getTextPosition();
|
var textPos = this.getTextPosition();
|
||||||
|
|
||||||
|
|
|
@ -321,6 +321,10 @@ GitVisuals.prototype.addBranch = function(branch) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitVisuals.prototype.removeVisBranch = function(visBranch) {
|
||||||
|
this.visBranchCollection.remove(visBranch);
|
||||||
|
};
|
||||||
|
|
||||||
GitVisuals.prototype.animateRefs = function(speed) {
|
GitVisuals.prototype.animateRefs = function(speed) {
|
||||||
this.visBranchCollection.each(function(visBranch) {
|
this.visBranchCollection.each(function(visBranch) {
|
||||||
visBranch.animateUpdatedPos(speed);
|
visBranch.animateUpdatedPos(speed);
|
||||||
|
|
8
todo.txt
8
todo.txt
|
@ -6,15 +6,11 @@ animation factory? stuff like:
|
||||||
-highlightCommit(50, 'targetColor') // during search
|
-highlightCommit(50, 'targetColor') // during search
|
||||||
-clearHighlightsAllNodes
|
-clearHighlightsAllNodes
|
||||||
|
|
||||||
ALSO other big things:
|
|
||||||
- Color on branch edges??
|
|
||||||
|
|
||||||
Big Graphic things:
|
Big Graphic things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
- colored branch edges. basically
|
|
||||||
- When you are rebasing and you hit the bottom, all the nodes go in the wrong spot...
|
- When you are rebasing and you hit the bottom, all the nodes go in the wrong spot...
|
||||||
We need some kind of "update everything but this set of nodes" thing...
|
|
||||||
- averaging colors!
|
- animateSnapshotFromTo(), then animate specific nodes
|
||||||
|
|
||||||
|
|
||||||
Medium things:
|
Medium things:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue