mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
moar
This commit is contained in:
parent
efabfa4378
commit
9b4de12074
3 changed files with 174 additions and 87 deletions
|
@ -974,7 +974,7 @@ GitEngine.prototype.rebaseStarter = function() {
|
|||
GitEngine.prototype.rebase = function(targetSource, currentLocation) {
|
||||
// first some conditions
|
||||
if (this.isUpstreamOf(targetSource, currentLocation)) {
|
||||
this.command.setResult('Branch already up-to-date');
|
||||
this.command.setResult(intl.str('git-result-uptodate'));
|
||||
|
||||
// git for some reason always checks out the branch you are rebasing,
|
||||
// no matter the result of the rebase
|
||||
|
@ -989,7 +989,7 @@ GitEngine.prototype.rebase = function(targetSource, currentLocation) {
|
|||
this.setTargetLocation(currentLocation, this.getCommitFromRef(targetSource));
|
||||
// we need the refresh tree animation to happen, so set the result directly
|
||||
// instead of throwing
|
||||
this.command.setResult('Fast-forwarding...');
|
||||
this.command.setResult(intl.str('git-result-fastforward'));
|
||||
|
||||
this.checkout(currentLocation);
|
||||
return;
|
||||
|
@ -1032,8 +1032,7 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
|
|||
// first if we are upstream of the target
|
||||
if (this.isUpstreamOf(currentLocation, targetSource)) {
|
||||
throw new GitError({
|
||||
msg: 'Nothing to do... (git throws a "noop" status here); ' +
|
||||
'Your source is upstream of your rebase target'
|
||||
msg: intl.str('git-result-nothing')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1066,7 +1065,7 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
|
|||
|
||||
if (!toRebase.length) {
|
||||
throw new GitError({
|
||||
msg: 'No commits to rebase! Everything is a merge commit'
|
||||
msg: intl.str('git-error-rebase-none')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1080,7 +1079,7 @@ GitEngine.prototype.rebaseInteractive = function(targetSource, currentLocation)
|
|||
// first, they might have dropped everything (annoying)
|
||||
if (!userSpecifiedRebase.length) {
|
||||
throw new CommandResult({
|
||||
msg: 'Nothing to do...'
|
||||
msg: intl.str('git-result-nothing')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1147,7 @@ GitEngine.prototype.rebaseFinish = function(toRebaseRough, stopSet, targetSource
|
|||
|
||||
if (!toRebase.length) {
|
||||
throw new GitError({
|
||||
msg: 'No Commits to Rebase! Everything else is merge commits or changes already have been applied'
|
||||
msg: intl.str('git-error-rebase-none')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1216,7 @@ GitEngine.prototype.merge = function(targetSource) {
|
|||
if (this.isUpstreamOf(targetSource, currentLocation) ||
|
||||
this.getCommitFromRef(targetSource) === this.getCommitFromRef(currentLocation)) {
|
||||
throw new CommandResult({
|
||||
msg: 'Branch already up-to-date'
|
||||
msg: intl.str('git-result-uptodate')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1225,7 +1224,7 @@ GitEngine.prototype.merge = function(targetSource) {
|
|||
// just set the target of this current location to the source
|
||||
this.setTargetLocation(currentLocation, this.getCommitFromRef(targetSource));
|
||||
// get fresh animation to happen
|
||||
this.command.setResult('Fast-forwarding...');
|
||||
this.command.setResult(intl.str('git-result-fastforward'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1234,9 +1233,13 @@ GitEngine.prototype.merge = function(targetSource) {
|
|||
var parent2 = this.getCommitFromRef(targetSource);
|
||||
|
||||
// we need a fancy commit message
|
||||
var msg = 'Merge ' + this.resolveName(targetSource) +
|
||||
' into ' + this.resolveName(currentLocation);
|
||||
|
||||
var msg = intl.str(
|
||||
'git-merge-msg',
|
||||
{
|
||||
target: this.resolveName(targetSource),
|
||||
current: this.resolveName(currentLocation)
|
||||
}
|
||||
);
|
||||
// since we specify parent 1 as the first parent, it is the "main" parent
|
||||
// and the node will be displayed below that branch / commit / whatever
|
||||
var mergeCommit = this.makeCommit(
|
||||
|
@ -1256,7 +1259,7 @@ GitEngine.prototype.checkoutStarter = function() {
|
|||
if (this.commandOptions['-b']) {
|
||||
if (this.generalArgs.length) {
|
||||
throw new GitError({
|
||||
msg: "I don't expect general args before -b!"
|
||||
msg: intl.str('git-error-options')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1275,7 +1278,7 @@ GitEngine.prototype.checkoutStarter = function() {
|
|||
var lastPlace = this.HEAD.get('lastLastTarget');
|
||||
if (!lastPlace) {
|
||||
throw new GitError({
|
||||
msg: 'Need a previous location to do - switching'
|
||||
msg: intl.str('git-result-nothing')
|
||||
});
|
||||
}
|
||||
this.HEAD.set('target', lastPlace);
|
||||
|
@ -1307,7 +1310,7 @@ GitEngine.prototype.checkout = function(idOrTarget) {
|
|||
var type = target.get('type');
|
||||
if (type !== 'branch' && type !== 'commit') {
|
||||
throw new GitError({
|
||||
msg: 'can only checkout branches and commits!'
|
||||
msg: intl.str('git-error-options')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1362,7 +1365,7 @@ GitEngine.prototype.forceBranch = function(branchName, where) {
|
|||
var branch = this.resolveID(branchName);
|
||||
if (branch.get('type') !== 'branch') {
|
||||
throw new GitError({
|
||||
msg: "Can't force move anything but a branch!!"
|
||||
msg: intl.str('git-error-options')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1379,19 +1382,13 @@ GitEngine.prototype.branch = function(name, ref) {
|
|||
GitEngine.prototype.deleteBranch = function(name) {
|
||||
// trying to delete, lets check our refs
|
||||
var target = this.resolveID(name);
|
||||
if (target.get('type') !== 'branch') {
|
||||
|
||||
if (target.get('type') !== 'branch' ||
|
||||
target.get('id') == 'master' ||
|
||||
this.HEAD.get('target') === target) {
|
||||
|
||||
throw new GitError({
|
||||
msg: "You can't delete things that arent branches with branch command"
|
||||
});
|
||||
}
|
||||
if (target.get('id') == 'master') {
|
||||
throw new GitError({
|
||||
msg: "You can't delete the master branch!"
|
||||
});
|
||||
}
|
||||
if (this.HEAD.get('target') === target) {
|
||||
throw new GitError({
|
||||
msg: "Cannot delete the branch you are currently on"
|
||||
msg: intl.str('git-error-brnach')
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue