This commit is contained in:
Peter Cottle 2013-08-05 10:16:58 -07:00
parent 62e56861cf
commit 4815a6f30b
3 changed files with 109 additions and 58 deletions

View file

@ -349,9 +349,17 @@ GitEngine.prototype.makeOrigin = function(treeString) {
this.getCommitFromRef(originTarget)
);
originBranch.set('remote', true);
// TODO
this.setLocalToTrackRemote();
}, this);
};
GitEngine.prototype.setLocalToTrackRemote = function(localBranch, remoteBranch) {
this.command.addWarning(
'local branch set to track remote branch'
);
};
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
if (createdSoFar[objID]) {
// base case
@ -866,7 +874,7 @@ GitEngine.prototype.push = function(options) {
// HAX HAX update o/master
chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(localBranch);
var remoteBranchID = localBranch.getRemoteBranchIDFromTracking();
var remoteBranchID = localBranch.getRemoteBranchID();
// less hacks hax
this.setTargetLocation(this.refs[remoteBranchID], localCommit);
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
@ -2248,30 +2256,39 @@ var Ref = Backbone.Model.extend({
var Branch = Ref.extend({
defaults: {
visBranch: null,
remoteTrackingBranch: null,
remoteTrackingBranchID: null,
localBranchesThatTrackThis: null,
remote: false
},
getRemoteBranchIDFromTracking: function() {
if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me');
}
// TODO check if remote tracking also
return 'o/' + this.getRemoteTrackingBranchName();
},
getRemoteTrackingBranchName: function() {
var originBranchName = this.get('remoteTrackingBranch');
return (originBranchName) ? originBranchName : this.get('id');
},
getIsRemote: function() {
return this.get('remote');
},
initialize: function() {
Ref.prototype.initialize.call(this);
this.set('type', 'branch');
},
setLocalBranchesThatTrackThis: function(branches) {
this.set('localBranchesThatTrackThis', branches);
},
getLocalBranchesThatTrackThis: function() {
return this.get('localBranchesThatTrackThis') || [];
},
addLocalBranchThatTracksThis: function(localBranch) {
this.setLocalBranchesThatTrackThis(
this.getLocalBranchesThatTrackThis().concat([localBranch])
);
},
getRemoteBranchID: function() {
if (this.getIsRemote()) {
throw new Error('I am a remote branch! dont try to get remote from me');
}
return 'o/' + this.get('id');
},
getIsRemote: function() {
return !!this.get('remote');
}
});