mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-02 18:54:27 +02:00
[Origin] Some origin work around remote branches
This commit is contained in:
parent
6080d324ce
commit
a24f62420d
8 changed files with 139 additions and 27 deletions
|
@ -5401,6 +5401,10 @@ require.define("/src/js/intl/strings.js",function(require,module,exports,__dirna
|
|||
'en_US': 'Quick commit. Go Bears!',
|
||||
'zh_CN': '快速提交。上啊月熊!'
|
||||
},
|
||||
'git-error-remote-branch': {
|
||||
'__desc__': 'One of the error messages for git',
|
||||
'en_US': 'You cannot execute that command on a remote branch'
|
||||
},
|
||||
'git-error-origin-required': {
|
||||
'__desc__': 'One of the error messages for git',
|
||||
'en_US': 'An origin is required for that command'
|
||||
|
@ -7502,12 +7506,27 @@ GitEngine.prototype.getBranches = function() {
|
|||
id: branch.get('id'),
|
||||
selected: this.HEAD.get('target') === branch,
|
||||
target: branch.get('target'),
|
||||
remote: branch.getIsRemote(),
|
||||
obj: branch
|
||||
});
|
||||
}, this);
|
||||
return toReturn;
|
||||
};
|
||||
|
||||
GitEngine.prototype.getRemoteBranches = function() {
|
||||
var all = this.getBranches();
|
||||
return _.filter(all, function(branchJSON) {
|
||||
return branchJSON.remote === true;
|
||||
});
|
||||
};
|
||||
|
||||
GitEngine.prototype.getLocalBranches = function() {
|
||||
var all = this.getBranches();
|
||||
return _.filter(all, function(branchJSON) {
|
||||
return branchJSON.remote === false;
|
||||
});
|
||||
};
|
||||
|
||||
GitEngine.prototype.printBranchesWithout = function(without) {
|
||||
var commitToBranches = this.getUpstreamBranchSet();
|
||||
var commitID = this.getCommitFromRef(without).get('id');
|
||||
|
@ -7783,7 +7802,7 @@ GitEngine.prototype.fetchStarter = function() {
|
|||
};
|
||||
|
||||
GitEngine.prototype.fetch = function() {
|
||||
// TODO refactor to use rebase animation stuff!!
|
||||
// TODO refactor to use rebase animation stuff!!!!
|
||||
// ok so we essentially are always in "-force" mode, since we always assume
|
||||
// the origin commits are downstream of where we are. Here is the outline:
|
||||
//
|
||||
|
@ -8624,7 +8643,15 @@ GitEngine.prototype.branchStarter = function() {
|
|||
|
||||
|
||||
if (this.generalArgs.length === 0) {
|
||||
this.printBranches(this.getBranches());
|
||||
var branches;
|
||||
if (this.commandOptions['-a']) {
|
||||
branches = this.getBranches();
|
||||
} else if (this.commandOptions['-r']) {
|
||||
branches = this.getRemoteBranches();
|
||||
} else {
|
||||
branches = this.getLocalBranches();
|
||||
}
|
||||
this.printBranches(branches);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -8633,12 +8660,19 @@ GitEngine.prototype.branchStarter = function() {
|
|||
};
|
||||
|
||||
GitEngine.prototype.forceBranch = function(branchName, where) {
|
||||
branchName = this.crappyUnescape(branchName);
|
||||
// if branchname doesn't exist...
|
||||
if (!this.refs[branchName]) {
|
||||
this.branch(branchName, where);
|
||||
}
|
||||
|
||||
var branch = this.resolveID(branchName);
|
||||
if (branch.getIsRemote()) {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-remote-branch')
|
||||
});
|
||||
}
|
||||
|
||||
if (branch.get('type') !== 'branch') {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-options')
|
||||
|
@ -8662,7 +8696,6 @@ GitEngine.prototype.deleteBranch = function(name) {
|
|||
if (target.get('type') !== 'branch' ||
|
||||
target.get('id') == 'master' ||
|
||||
this.HEAD.get('target') === target) {
|
||||
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-branch')
|
||||
});
|
||||
|
@ -8670,6 +8703,12 @@ GitEngine.prototype.deleteBranch = function(name) {
|
|||
|
||||
// now we know it's a branch
|
||||
var branch = target;
|
||||
// if its remote
|
||||
if (target.getIsRemote()) {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-remote-branch')
|
||||
});
|
||||
}
|
||||
|
||||
this.branchCollection.remove(branch);
|
||||
this.refs[branch.get('id')] = undefined;
|
||||
|
@ -13416,6 +13455,8 @@ GitOptionParser.prototype.getMasterOptionMap = function() {
|
|||
'-d': false,
|
||||
'-D': false,
|
||||
'-f': false,
|
||||
'-a': false,
|
||||
'-r': false,
|
||||
'--contains': false
|
||||
},
|
||||
checkout: {
|
||||
|
@ -22579,6 +22620,8 @@ GitOptionParser.prototype.getMasterOptionMap = function() {
|
|||
'-d': false,
|
||||
'-D': false,
|
||||
'-f': false,
|
||||
'-a': false,
|
||||
'-r': false,
|
||||
'--contains': false
|
||||
},
|
||||
checkout: {
|
||||
|
@ -23247,12 +23290,27 @@ GitEngine.prototype.getBranches = function() {
|
|||
id: branch.get('id'),
|
||||
selected: this.HEAD.get('target') === branch,
|
||||
target: branch.get('target'),
|
||||
remote: branch.getIsRemote(),
|
||||
obj: branch
|
||||
});
|
||||
}, this);
|
||||
return toReturn;
|
||||
};
|
||||
|
||||
GitEngine.prototype.getRemoteBranches = function() {
|
||||
var all = this.getBranches();
|
||||
return _.filter(all, function(branchJSON) {
|
||||
return branchJSON.remote === true;
|
||||
});
|
||||
};
|
||||
|
||||
GitEngine.prototype.getLocalBranches = function() {
|
||||
var all = this.getBranches();
|
||||
return _.filter(all, function(branchJSON) {
|
||||
return branchJSON.remote === false;
|
||||
});
|
||||
};
|
||||
|
||||
GitEngine.prototype.printBranchesWithout = function(without) {
|
||||
var commitToBranches = this.getUpstreamBranchSet();
|
||||
var commitID = this.getCommitFromRef(without).get('id');
|
||||
|
@ -23528,7 +23586,7 @@ GitEngine.prototype.fetchStarter = function() {
|
|||
};
|
||||
|
||||
GitEngine.prototype.fetch = function() {
|
||||
// TODO refactor to use rebase animation stuff!!
|
||||
// TODO refactor to use rebase animation stuff!!!!
|
||||
// ok so we essentially are always in "-force" mode, since we always assume
|
||||
// the origin commits are downstream of where we are. Here is the outline:
|
||||
//
|
||||
|
@ -24369,7 +24427,15 @@ GitEngine.prototype.branchStarter = function() {
|
|||
|
||||
|
||||
if (this.generalArgs.length === 0) {
|
||||
this.printBranches(this.getBranches());
|
||||
var branches;
|
||||
if (this.commandOptions['-a']) {
|
||||
branches = this.getBranches();
|
||||
} else if (this.commandOptions['-r']) {
|
||||
branches = this.getRemoteBranches();
|
||||
} else {
|
||||
branches = this.getLocalBranches();
|
||||
}
|
||||
this.printBranches(branches);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -24378,12 +24444,19 @@ GitEngine.prototype.branchStarter = function() {
|
|||
};
|
||||
|
||||
GitEngine.prototype.forceBranch = function(branchName, where) {
|
||||
branchName = this.crappyUnescape(branchName);
|
||||
// if branchname doesn't exist...
|
||||
if (!this.refs[branchName]) {
|
||||
this.branch(branchName, where);
|
||||
}
|
||||
|
||||
var branch = this.resolveID(branchName);
|
||||
if (branch.getIsRemote()) {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-remote-branch')
|
||||
});
|
||||
}
|
||||
|
||||
if (branch.get('type') !== 'branch') {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-options')
|
||||
|
@ -24407,7 +24480,6 @@ GitEngine.prototype.deleteBranch = function(name) {
|
|||
if (target.get('type') !== 'branch' ||
|
||||
target.get('id') == 'master' ||
|
||||
this.HEAD.get('target') === target) {
|
||||
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-branch')
|
||||
});
|
||||
|
@ -24415,6 +24487,12 @@ GitEngine.prototype.deleteBranch = function(name) {
|
|||
|
||||
// now we know it's a branch
|
||||
var branch = target;
|
||||
// if its remote
|
||||
if (target.getIsRemote()) {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-remote-branch')
|
||||
});
|
||||
}
|
||||
|
||||
this.branchCollection.remove(branch);
|
||||
this.refs[branch.get('id')] = undefined;
|
||||
|
@ -25331,6 +25409,10 @@ require.define("/src/js/intl/strings.js",function(require,module,exports,__dirna
|
|||
'en_US': 'Quick commit. Go Bears!',
|
||||
'zh_CN': '快速提交。上啊月熊!'
|
||||
},
|
||||
'git-error-remote-branch': {
|
||||
'__desc__': 'One of the error messages for git',
|
||||
'en_US': 'You cannot execute that command on a remote branch'
|
||||
},
|
||||
'git-error-origin-required': {
|
||||
'__desc__': 'One of the error messages for git',
|
||||
'en_US': 'An origin is required for that command'
|
||||
|
|
File diff suppressed because one or more lines are too long
1
build/bundle.min.js
vendored
1
build/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -426,7 +426,7 @@
|
|||
For a much easier time perusing the source, see the individual files at:
|
||||
https://github.com/pcottle/learnGitBranching
|
||||
-->
|
||||
<script src="build/bundle.min.6b104704.js"></script>
|
||||
<script src="build/bundle.js"></script>
|
||||
|
||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
||||
The downside? No raw logs to parse for analytics, so I have to include
|
||||
|
|
|
@ -132,6 +132,8 @@ GitOptionParser.prototype.getMasterOptionMap = function() {
|
|||
'-d': false,
|
||||
'-D': false,
|
||||
'-f': false,
|
||||
'-a': false,
|
||||
'-r': false,
|
||||
'--contains': false
|
||||
},
|
||||
checkout: {
|
||||
|
|
|
@ -453,12 +453,27 @@ GitEngine.prototype.getBranches = function() {
|
|||
id: branch.get('id'),
|
||||
selected: this.HEAD.get('target') === branch,
|
||||
target: branch.get('target'),
|
||||
remote: branch.getIsRemote(),
|
||||
obj: branch
|
||||
});
|
||||
}, this);
|
||||
return toReturn;
|
||||
};
|
||||
|
||||
GitEngine.prototype.getRemoteBranches = function() {
|
||||
var all = this.getBranches();
|
||||
return _.filter(all, function(branchJSON) {
|
||||
return branchJSON.remote === true;
|
||||
});
|
||||
};
|
||||
|
||||
GitEngine.prototype.getLocalBranches = function() {
|
||||
var all = this.getBranches();
|
||||
return _.filter(all, function(branchJSON) {
|
||||
return branchJSON.remote === false;
|
||||
});
|
||||
};
|
||||
|
||||
GitEngine.prototype.printBranchesWithout = function(without) {
|
||||
var commitToBranches = this.getUpstreamBranchSet();
|
||||
var commitID = this.getCommitFromRef(without).get('id');
|
||||
|
@ -734,7 +749,7 @@ GitEngine.prototype.fetchStarter = function() {
|
|||
};
|
||||
|
||||
GitEngine.prototype.fetch = function() {
|
||||
// TODO refactor to use rebase animation stuff!!
|
||||
// TODO refactor to use rebase animation stuff!!!!
|
||||
// ok so we essentially are always in "-force" mode, since we always assume
|
||||
// the origin commits are downstream of where we are. Here is the outline:
|
||||
//
|
||||
|
@ -1575,7 +1590,15 @@ GitEngine.prototype.branchStarter = function() {
|
|||
|
||||
|
||||
if (this.generalArgs.length === 0) {
|
||||
this.printBranches(this.getBranches());
|
||||
var branches;
|
||||
if (this.commandOptions['-a']) {
|
||||
branches = this.getBranches();
|
||||
} else if (this.commandOptions['-r']) {
|
||||
branches = this.getRemoteBranches();
|
||||
} else {
|
||||
branches = this.getLocalBranches();
|
||||
}
|
||||
this.printBranches(branches);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1584,12 +1607,19 @@ GitEngine.prototype.branchStarter = function() {
|
|||
};
|
||||
|
||||
GitEngine.prototype.forceBranch = function(branchName, where) {
|
||||
branchName = this.crappyUnescape(branchName);
|
||||
// if branchname doesn't exist...
|
||||
if (!this.refs[branchName]) {
|
||||
this.branch(branchName, where);
|
||||
}
|
||||
|
||||
var branch = this.resolveID(branchName);
|
||||
if (branch.getIsRemote()) {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-remote-branch')
|
||||
});
|
||||
}
|
||||
|
||||
if (branch.get('type') !== 'branch') {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-options')
|
||||
|
@ -1613,7 +1643,6 @@ GitEngine.prototype.deleteBranch = function(name) {
|
|||
if (target.get('type') !== 'branch' ||
|
||||
target.get('id') == 'master' ||
|
||||
this.HEAD.get('target') === target) {
|
||||
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-branch')
|
||||
});
|
||||
|
@ -1621,6 +1650,12 @@ GitEngine.prototype.deleteBranch = function(name) {
|
|||
|
||||
// now we know it's a branch
|
||||
var branch = target;
|
||||
// if its remote
|
||||
if (target.getIsRemote()) {
|
||||
throw new GitError({
|
||||
msg: intl.str('git-error-remote-branch')
|
||||
});
|
||||
}
|
||||
|
||||
this.branchCollection.remove(branch);
|
||||
this.refs[branch.get('id')] = undefined;
|
||||
|
|
|
@ -52,6 +52,10 @@ exports.strings = {
|
|||
'en_US': 'Quick commit. Go Bears!',
|
||||
'zh_CN': '快速提交。上啊月熊!'
|
||||
},
|
||||
'git-error-remote-branch': {
|
||||
'__desc__': 'One of the error messages for git',
|
||||
'en_US': 'You cannot execute that command on a remote branch'
|
||||
},
|
||||
'git-error-origin-required': {
|
||||
'__desc__': 'One of the error messages for git',
|
||||
'en_US': 'An origin is required for that command'
|
||||
|
|
21
todo.txt
21
todo.txt
|
@ -1,6 +1,6 @@
|
|||
Mega Things
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[ ] origin support
|
||||
[-] origin support
|
||||
|
||||
Intl TODO
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -13,21 +13,9 @@ Big Things
|
|||
|
||||
Origin things:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[ ] setup remote model, for now it just has:
|
||||
-- a name
|
||||
-- a URL (default for now)?
|
||||
-- points to a completely new git engine instance to interact with
|
||||
[ ] Setup branch model to include:
|
||||
-- is remote (custom getter)
|
||||
-- remote it is on (if applicable), just points to a remote model
|
||||
-- remote branch it is tracking (points to a remote branch model)
|
||||
-- set checkout -b branch __remoteBranch to track the remote branch
|
||||
|
||||
[ ] fix checkout to:
|
||||
-- if you go to __remoteBranch, it just goes to the commit since its read-only.
|
||||
|
||||
[ ] fix branch -f to:
|
||||
-- not allow moving remote branches?
|
||||
[-] remote branch it is tracking (points to a remote branch model)
|
||||
[ ] set checkout -b branch __remoteBranch to track the remote branch
|
||||
|
||||
[ ] fix branch -a and branch -r to:
|
||||
-- show remote branches or all branches
|
||||
|
@ -57,6 +45,9 @@ Ideas for cleaning
|
|||
Done things:
|
||||
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[x] fix branch -f to not allow moving remote branches?
|
||||
[x] fix checkout to: if you go to __remoteBranch, it just goes to the commit since its read-only.
|
||||
[x] is remote (custom getter)
|
||||
[x] hash agnotisc comparison with asserts for ammends
|
||||
[x] level builder intl aware
|
||||
[x] rest of views/index translation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue