mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
PR #196 code cleanup and solution description rather than reordering
This commit is contained in:
parent
ffc974e03f
commit
90c39417bb
4 changed files with 27 additions and 52 deletions
|
@ -2184,26 +2184,19 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation,
|
||||||
if (options.initialCommitOrdering && options.initialCommitOrdering.length > 0) {
|
if (options.initialCommitOrdering && options.initialCommitOrdering.length > 0) {
|
||||||
var rebaseMap = {};
|
var rebaseMap = {};
|
||||||
_.each(toRebase, function(commit) {
|
_.each(toRebase, function(commit) {
|
||||||
var id = commit.get('id');
|
rebaseMap[commit.get('id')] = true;
|
||||||
rebaseMap[id] = commit;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verify each chosen commit exists in the list of commits given to the user
|
// Verify each chosen commit exists in the list of commits given to the user
|
||||||
var extraCommits = [];
|
|
||||||
initialCommitOrdering = [];
|
initialCommitOrdering = [];
|
||||||
_.each(options.initialCommitOrdering[0].split(','), function(id) {
|
_.each(options.initialCommitOrdering[0].split(','), function(id) {
|
||||||
if (id in rebaseMap) {
|
if (!rebaseMap[id]) {
|
||||||
initialCommitOrdering.push(rebaseMap[id]);
|
|
||||||
} else {
|
|
||||||
extraCommits.push(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (extraCommits.length > 0) {
|
|
||||||
throw new GitError({
|
throw new GitError({
|
||||||
msg: intl.todo('Hey those commits dont exist in the set!')
|
msg: intl.todo('Hey those commits dont exist in the set!')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
initialCommitOrdering.push(id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// The rebase view expects the commits reversed, so do that here
|
// The rebase view expects the commits reversed, so do that here
|
||||||
|
|
|
@ -13,54 +13,24 @@ var InteractiveRebaseView = ContainedBase.extend({
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
template: _.template($('#interactive-rebase-template').html()),
|
template: _.template($('#interactive-rebase-template').html()),
|
||||||
|
|
||||||
createRebaseEntries: function() {
|
|
||||||
this.rebaseMap = {};
|
|
||||||
this.entryObjMap = {};
|
|
||||||
this.rebaseEntries = new RebaseEntryCollection();
|
|
||||||
|
|
||||||
// If we are displaying a solution, we potentially only want to pick certain commits, and reorder
|
|
||||||
// the ones that are picked. The commits we want to pick and the order are contained in the options.initialCommitOrdering,
|
|
||||||
// the list of all the commits that are part of the rebase are in options.toRebase
|
|
||||||
var commitsToUse = this.options.initialCommitOrdering === undefined ? this.options.toRebase
|
|
||||||
: this.options.initialCommitOrdering;
|
|
||||||
|
|
||||||
_.each(commitsToUse, function(commit) {
|
|
||||||
var id = commit.get('id');
|
|
||||||
this.rebaseMap[id] = commit;
|
|
||||||
|
|
||||||
// make basic models for each commit
|
|
||||||
this.entryObjMap[id] = new RebaseEntry({
|
|
||||||
id: id,
|
|
||||||
pick: true
|
|
||||||
});
|
|
||||||
this.rebaseEntries.add(this.entryObjMap[id]);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// If we are using the initialCommitOrdering, we might not have picked all of the commits,
|
|
||||||
// but we would still want to see the other unpicked ones. Just show them as unpicked by default
|
|
||||||
if (this.options.initialCommitOrdering !== undefined) {
|
|
||||||
_.each(this.options.toRebase, function(commit) {
|
|
||||||
var id = commit.get('id');
|
|
||||||
|
|
||||||
if (!(id in this.rebaseMap)) {
|
|
||||||
this.rebaseMap[id] = commit;
|
|
||||||
|
|
||||||
// make basic models for each commit
|
|
||||||
this.entryObjMap[id] = new RebaseEntry({
|
|
||||||
id: id,
|
|
||||||
pick: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.rebaseEntries.add(this.entryObjMap[id]);
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.deferred = options.deferred;
|
this.deferred = options.deferred;
|
||||||
|
this.rebaseMap = {};
|
||||||
|
this.entryObjMap = {};
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
this.createRebaseEntries();
|
this.rebaseEntries = new RebaseEntryCollection();
|
||||||
|
options.toRebase.reverse();
|
||||||
|
_.each(options.toRebase, function(commit) {
|
||||||
|
var id = commit.get('id');
|
||||||
|
this.rebaseMap[id] = commit;
|
||||||
|
|
||||||
|
// make basic models for each commit
|
||||||
|
this.entryObjMap[id] = new RebaseEntry({
|
||||||
|
id: id
|
||||||
|
});
|
||||||
|
this.rebaseEntries.add(this.entryObjMap[id]);
|
||||||
|
}, this);
|
||||||
|
|
||||||
this.container = new ModalTerminal({
|
this.container = new ModalTerminal({
|
||||||
title: 'Interactive Rebase'
|
title: 'Interactive Rebase'
|
||||||
|
@ -110,7 +80,8 @@ var InteractiveRebaseView = ContainedBase.extend({
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var json = {
|
var json = {
|
||||||
num: _.keys(this.rebaseMap).length
|
num: _.keys(this.rebaseMap).length,
|
||||||
|
solutionOrder: this.options.initialCommitOrdering
|
||||||
};
|
};
|
||||||
|
|
||||||
var destination = this.container.getInsideElement();
|
var destination = this.container.getInsideElement();
|
||||||
|
@ -200,7 +171,6 @@ var RebaseEntryView = Backbone.View.extend({
|
||||||
|
|
||||||
// hacky :( who would have known jquery barfs on ids with %'s and quotes
|
// hacky :( who would have known jquery barfs on ids with %'s and quotes
|
||||||
this.listEntry = this.$el.children(':last');
|
this.listEntry = this.$el.children(':last');
|
||||||
this.listEntry.toggleClass('notPicked', !this.model.get('pick'));
|
|
||||||
|
|
||||||
this.listEntry.delegate('#toggleButton', 'click', _.bind(function() {
|
this.listEntry.delegate('#toggleButton', 'click', _.bind(function() {
|
||||||
this.toggle();
|
this.toggle();
|
||||||
|
|
|
@ -692,6 +692,12 @@ div.terminal-text p.helperText,
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.iRebaseDialog p.solutionText {
|
||||||
|
color: lime;
|
||||||
|
font-weight: bold;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.iRebaseDialog p.helperText {
|
.iRebaseDialog p.helperText {
|
||||||
color: #999;
|
color: #999;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
@ -413,6 +413,12 @@
|
||||||
<p>
|
<p>
|
||||||
Rebasing <%= num %> Commits
|
Rebasing <%= num %> Commits
|
||||||
</p>
|
</p>
|
||||||
|
<% if (solutionOrder && solutionOrder.length) { %>
|
||||||
|
<p class="solutionText">
|
||||||
|
For the solution, order the commits as
|
||||||
|
<%= solutionOrder.join(', ') %>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
<p class="helperText">
|
<p class="helperText">
|
||||||
(Drag and drop to re-order. Toggle the "pick" button to omit or re-add a commit)
|
(Drag and drop to re-order. Toggle the "pick" button to omit or re-add a commit)
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue