mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-03 11:14:27 +02:00
much better interaction on levels keys with tabs
This commit is contained in:
parent
12e921a781
commit
c522722513
4 changed files with 56 additions and 2 deletions
|
@ -304,5 +304,19 @@ describe('Git Remotes', function() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('doesnt let you fetch to master if you are checked out there', function() {
|
||||||
|
expectTreeAsync(
|
||||||
|
'git clone; git push master:foo; git fakeTeamwork foo 2; git fetch origin foo^:blah; git fetch foo:master',
|
||||||
|
'{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null},"o/foo":{"target":"C1","id":"o/foo","remoteTrackingBranchID":null},"blah":{"target":"C2","id":"blah","remoteTrackingBranchID":null}},"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","remoteTrackingBranchID":null},"foo":{"target":"C3","id":"foo","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C2"],"id":"C3"}},"HEAD":{"target":"foo","id":"HEAD"}}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('doesnt let you delete branches that dont exist', function() {
|
||||||
|
expectTreeAsync(
|
||||||
|
'git clone; git push :foo',
|
||||||
|
'{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -685,6 +685,13 @@ var commandConfig = {
|
||||||
var refspecParts = firstArg.split(':');
|
var refspecParts = firstArg.split(':');
|
||||||
source = refspecParts[0];
|
source = refspecParts[0];
|
||||||
destination = validateBranchName(engine, refspecParts[1]);
|
destination = validateBranchName(engine, refspecParts[1]);
|
||||||
|
if (source === "" && !engine.origin.refs[options.destination]) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: intl.todo(
|
||||||
|
'cannot delete branch ' + options.destination + ' which doesnt exist'
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (firstArg) {
|
if (firstArg) {
|
||||||
// we are using this arg as destination AND source. the dest branch
|
// we are using this arg as destination AND source. the dest branch
|
||||||
|
|
|
@ -89,6 +89,10 @@ var LevelDropdownView = ContainedBase.extend({
|
||||||
if (id === this.JSON.selectedTab) {
|
if (id === this.JSON.selectedTab) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.updateTabTo(id);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateTabTo: function(id) {
|
||||||
this.JSON.selectedTab = id;
|
this.JSON.selectedTab = id;
|
||||||
this.render();
|
this.render();
|
||||||
if (this.selectedID) {
|
if (this.selectedID) {
|
||||||
|
@ -119,7 +123,24 @@ var LevelDropdownView = ContainedBase.extend({
|
||||||
|
|
||||||
leftOrRight: function(delta) {
|
leftOrRight: function(delta) {
|
||||||
this.deselectIconByID(this.selectedID);
|
this.deselectIconByID(this.selectedID);
|
||||||
this.selectedIndex = this.wrapIndex(this.selectedIndex + delta, this.getCurrentSequence());
|
var index = this.selectedIndex + delta;
|
||||||
|
|
||||||
|
var sequence = this.getCurrentSequence();
|
||||||
|
var tabs = this.JSON.tabs;
|
||||||
|
// switch tabs now if needed / possible
|
||||||
|
if (index >= sequence.length &&
|
||||||
|
this.getTabIndex() + 1 < tabs.length) {
|
||||||
|
this.switchToTabIndex(this.getTabIndex() + 1);
|
||||||
|
this.selectedIndex = 0;
|
||||||
|
} else if (index < 0 &&
|
||||||
|
this.getTabIndex() - 1 >= 0) {
|
||||||
|
this.switchToTabIndex(this.getTabIndex() - 1);
|
||||||
|
this.selectedIndex = 0;
|
||||||
|
} else {
|
||||||
|
this.selectedIndex = this.wrapIndex(
|
||||||
|
this.selectedIndex + delta, this.getCurrentSequence()
|
||||||
|
);
|
||||||
|
}
|
||||||
this.updateSelectedIcon();
|
this.updateSelectedIcon();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -168,6 +189,18 @@ var LevelDropdownView = ContainedBase.extend({
|
||||||
this.selectedSequence = undefined;
|
this.selectedSequence = undefined;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTabIndex: function() {
|
||||||
|
var ids = _.map(this.JSON.tabs, function(tab) {
|
||||||
|
return tab.id;
|
||||||
|
});
|
||||||
|
return ids.indexOf(this.JSON.selectedTab);
|
||||||
|
},
|
||||||
|
|
||||||
|
switchToTabIndex: function(index) {
|
||||||
|
var tabID = this.JSON.tabs[index].id;
|
||||||
|
this.updateTabTo(tabID);
|
||||||
|
},
|
||||||
|
|
||||||
wrapIndex: function(index, arr) {
|
wrapIndex: function(index, arr) {
|
||||||
index = (index >= arr.length) ? 0 : index;
|
index = (index >= arr.length) ? 0 : index;
|
||||||
index = (index < 0) ? arr.length - 1 : index;
|
index = (index < 0) ? arr.length - 1 : index;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue