mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
Issue #129 pushing to different remote branches
This commit is contained in:
parent
7034eb76fa
commit
bfd8483d90
8 changed files with 165 additions and 114 deletions
172
build/bundle.js
172
build/bundle.js
|
@ -8087,14 +8087,15 @@ GitEngine.prototype.descendSortDepth = function(objects) {
|
|||
|
||||
GitEngine.prototype.push = function(options) {
|
||||
options = options || {};
|
||||
var localBranch = this.refs['master'];
|
||||
var remoteBranch = this.origin.refs['master'];
|
||||
var localBranch = this.getOneBeforeCommit('HEAD');
|
||||
var remoteBranch = this.refs[options.destination];
|
||||
var branchOnRemote = this.origin.refs[remoteBranch.getBaseID()];
|
||||
|
||||
// first check if this is even allowed by checking the sync between
|
||||
this.checkUpstreamOfSource(
|
||||
this,
|
||||
this.origin,
|
||||
remoteBranch,
|
||||
branchOnRemote,
|
||||
localBranch,
|
||||
intl.str('git-error-origin-push-no-ff')
|
||||
);
|
||||
|
@ -8102,7 +8103,7 @@ GitEngine.prototype.push = function(options) {
|
|||
var commitsToMake = this.getTargetGraphDifference(
|
||||
this.origin,
|
||||
this,
|
||||
remoteBranch,
|
||||
branchOnRemote,
|
||||
localBranch
|
||||
);
|
||||
|
||||
|
@ -8139,7 +8140,7 @@ GitEngine.prototype.push = function(options) {
|
|||
chain = chain.then(_.bind(function() {
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.refs[commitJSON.id],
|
||||
remoteBranch
|
||||
branchOnRemote
|
||||
);
|
||||
}, this));
|
||||
|
||||
|
@ -8154,7 +8155,7 @@ GitEngine.prototype.push = function(options) {
|
|||
chain = chain.then(_.bind(function() {
|
||||
var localLocationID = localBranch.get('target').get('id');
|
||||
var remoteCommit = this.origin.refs[localLocationID];
|
||||
this.origin.setTargetLocation(remoteBranch, remoteCommit);
|
||||
this.origin.setTargetLocation(branchOnRemote, remoteCommit);
|
||||
// unhighlight local
|
||||
this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
|
||||
|
@ -8163,9 +8164,7 @@ GitEngine.prototype.push = function(options) {
|
|||
// HAX HAX update master and remote tracking for master
|
||||
chain = chain.then(_.bind(function() {
|
||||
var localCommit = this.getCommitFromRef(localBranch);
|
||||
var remoteBranchID = localBranch.getRemoteTrackingBranchID();
|
||||
// less hacks hax
|
||||
this.setTargetLocation(this.refs[remoteBranchID], localCommit);
|
||||
this.setTargetLocation(remoteBranch, localCommit);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}, this));
|
||||
|
||||
|
@ -10769,7 +10768,17 @@ var crappyUnescape = function(str) {
|
|||
return str.replace(/'/g, "'").replace(///g, "/");
|
||||
};
|
||||
|
||||
var ensureBranchIsRemoteTracking = function(engine, branchName) {
|
||||
var assertOriginSpecified = function(generalArgs) {
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var assertBranchIsRemoteTracking = function(engine, branchName) {
|
||||
branchName = crappyUnescape(branchName);
|
||||
if (!engine.refs[branchName]) {
|
||||
throw new GitError({
|
||||
|
@ -10905,37 +10914,28 @@ var commandConfig = {
|
|||
// so lets switch on A/B here
|
||||
|
||||
var commandOptions = command.getOptionsMap();
|
||||
var options = {
|
||||
isRebase: commandOptions['--rebase']
|
||||
};
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
var tracking;
|
||||
if (generalArgs[1]) {
|
||||
tracking = ensureBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
options.source = tracking;
|
||||
tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
} else {
|
||||
// cant be detached
|
||||
if (engine.getDetachedHead()) {
|
||||
throw new GitError({
|
||||
msg: intl.todo('Git pull can not be executed in detached HEAD mode!')
|
||||
msg: intl.todo('Git pull can not be executed in detached HEAD mode if no remote branch specified!')
|
||||
});
|
||||
}
|
||||
var oneBefore = engine.getOneBeforeCommit('HEAD');
|
||||
tracking = ensureBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
options.source = tracking;
|
||||
tracking = assertBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
}
|
||||
|
||||
engine.pull(options);
|
||||
engine.pull({
|
||||
source: tracking,
|
||||
isRebase: commandOptions['--rebase']
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -11007,16 +11007,10 @@ var commandConfig = {
|
|||
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
if (generalArgs[1]) {
|
||||
var tracking = ensureBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
var tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
options.branches = [engine.refs[tracking]];
|
||||
}
|
||||
|
||||
|
@ -11299,8 +11293,26 @@ var commandConfig = {
|
|||
msg: intl.str('git-error-origin-required')
|
||||
});
|
||||
}
|
||||
command.acceptNoGeneralArgs();
|
||||
engine.push();
|
||||
|
||||
var options = {};
|
||||
// git push is pretty complex in terms of
|
||||
// the arguments it wants as well -- see
|
||||
// git pull for a more detailed description.
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
var tracking;
|
||||
if (generalArgs[1]) {
|
||||
tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
} else {
|
||||
var oneBefore = engine.getOneBeforeCommit('HEAD');
|
||||
tracking = assertBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
}
|
||||
|
||||
engine.push({
|
||||
destination: tracking
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -25364,7 +25376,17 @@ var crappyUnescape = function(str) {
|
|||
return str.replace(/'/g, "'").replace(///g, "/");
|
||||
};
|
||||
|
||||
var ensureBranchIsRemoteTracking = function(engine, branchName) {
|
||||
var assertOriginSpecified = function(generalArgs) {
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var assertBranchIsRemoteTracking = function(engine, branchName) {
|
||||
branchName = crappyUnescape(branchName);
|
||||
if (!engine.refs[branchName]) {
|
||||
throw new GitError({
|
||||
|
@ -25500,37 +25522,28 @@ var commandConfig = {
|
|||
// so lets switch on A/B here
|
||||
|
||||
var commandOptions = command.getOptionsMap();
|
||||
var options = {
|
||||
isRebase: commandOptions['--rebase']
|
||||
};
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
var tracking;
|
||||
if (generalArgs[1]) {
|
||||
tracking = ensureBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
options.source = tracking;
|
||||
tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
} else {
|
||||
// cant be detached
|
||||
if (engine.getDetachedHead()) {
|
||||
throw new GitError({
|
||||
msg: intl.todo('Git pull can not be executed in detached HEAD mode!')
|
||||
msg: intl.todo('Git pull can not be executed in detached HEAD mode if no remote branch specified!')
|
||||
});
|
||||
}
|
||||
var oneBefore = engine.getOneBeforeCommit('HEAD');
|
||||
tracking = ensureBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
options.source = tracking;
|
||||
tracking = assertBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
}
|
||||
|
||||
engine.pull(options);
|
||||
engine.pull({
|
||||
source: tracking,
|
||||
isRebase: commandOptions['--rebase']
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -25602,16 +25615,10 @@ var commandConfig = {
|
|||
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
if (generalArgs[1]) {
|
||||
var tracking = ensureBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
var tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
options.branches = [engine.refs[tracking]];
|
||||
}
|
||||
|
||||
|
@ -25894,8 +25901,26 @@ var commandConfig = {
|
|||
msg: intl.str('git-error-origin-required')
|
||||
});
|
||||
}
|
||||
command.acceptNoGeneralArgs();
|
||||
engine.push();
|
||||
|
||||
var options = {};
|
||||
// git push is pretty complex in terms of
|
||||
// the arguments it wants as well -- see
|
||||
// git pull for a more detailed description.
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
var tracking;
|
||||
if (generalArgs[1]) {
|
||||
tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
} else {
|
||||
var oneBefore = engine.getOneBeforeCommit('HEAD');
|
||||
tracking = assertBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
}
|
||||
|
||||
engine.push({
|
||||
destination: tracking
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -27026,14 +27051,15 @@ GitEngine.prototype.descendSortDepth = function(objects) {
|
|||
|
||||
GitEngine.prototype.push = function(options) {
|
||||
options = options || {};
|
||||
var localBranch = this.refs['master'];
|
||||
var remoteBranch = this.origin.refs['master'];
|
||||
var localBranch = this.getOneBeforeCommit('HEAD');
|
||||
var remoteBranch = this.refs[options.destination];
|
||||
var branchOnRemote = this.origin.refs[remoteBranch.getBaseID()];
|
||||
|
||||
// first check if this is even allowed by checking the sync between
|
||||
this.checkUpstreamOfSource(
|
||||
this,
|
||||
this.origin,
|
||||
remoteBranch,
|
||||
branchOnRemote,
|
||||
localBranch,
|
||||
intl.str('git-error-origin-push-no-ff')
|
||||
);
|
||||
|
@ -27041,7 +27067,7 @@ GitEngine.prototype.push = function(options) {
|
|||
var commitsToMake = this.getTargetGraphDifference(
|
||||
this.origin,
|
||||
this,
|
||||
remoteBranch,
|
||||
branchOnRemote,
|
||||
localBranch
|
||||
);
|
||||
|
||||
|
@ -27078,7 +27104,7 @@ GitEngine.prototype.push = function(options) {
|
|||
chain = chain.then(_.bind(function() {
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.refs[commitJSON.id],
|
||||
remoteBranch
|
||||
branchOnRemote
|
||||
);
|
||||
}, this));
|
||||
|
||||
|
@ -27093,7 +27119,7 @@ GitEngine.prototype.push = function(options) {
|
|||
chain = chain.then(_.bind(function() {
|
||||
var localLocationID = localBranch.get('target').get('id');
|
||||
var remoteCommit = this.origin.refs[localLocationID];
|
||||
this.origin.setTargetLocation(remoteBranch, remoteCommit);
|
||||
this.origin.setTargetLocation(branchOnRemote, remoteCommit);
|
||||
// unhighlight local
|
||||
this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
|
||||
|
@ -27102,9 +27128,7 @@ GitEngine.prototype.push = function(options) {
|
|||
// HAX HAX update master and remote tracking for master
|
||||
chain = chain.then(_.bind(function() {
|
||||
var localCommit = this.getCommitFromRef(localBranch);
|
||||
var remoteBranchID = localBranch.getRemoteTrackingBranchID();
|
||||
// less hacks hax
|
||||
this.setTargetLocation(this.refs[remoteBranchID], localCommit);
|
||||
this.setTargetLocation(remoteBranch, localCommit);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}, this));
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
1
build/bundle.min.22a6fc52.js
Normal file
1
build/bundle.min.22a6fc52.js
Normal file
File diff suppressed because one or more lines are too long
2
build/bundle.min.js
vendored
2
build/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -445,7 +445,7 @@
|
|||
For a much easier time perusing the source, see the individual files at:
|
||||
https://github.com/pcottle/learnGitBranching
|
||||
-->
|
||||
<script src="build/bundle.min.0b3ef8c2.js"></script>
|
||||
<script src="build/bundle.min.22a6fc52.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
|
||||
|
|
|
@ -99,5 +99,20 @@ describe('Git Remotes', function() {
|
|||
'%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C3%27%22%2C%22id%22%3A%22master%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C1%22%2C%22id%22%3A%22side%22%7D%2C%22o/master%22%3A%7B%22target%22%3A%22C1%22%2C%22id%22%3A%22o/master%22%7D%2C%22o/side%22%3A%7B%22target%22%3A%22C2%22%2C%22id%22%3A%22o/side%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C3%27%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22master%22%2C%22id%22%3A%22HEAD%22%7D%2C%22originTree%22%3A%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C1%22%2C%22id%22%3A%22master%22%7D%2C%22side%22%3A%7B%22target%22%3A%22C2%22%2C%22id%22%3A%22side%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22side%22%2C%22id%22%3A%22HEAD%22%7D%7D%7D'
|
||||
);
|
||||
});
|
||||
|
||||
it('pushes to another remote', function() {
|
||||
expectTreeAsync(
|
||||
'git branch side; git clone;git commit; git push origin side',
|
||||
'{"branches":{"master":{"target":"C2","id":"master"},"side":{"target":"C1","id":"side"},"o/master":{"target":"C1","id":"o/master"},"o/side":{"target":"C2","id":"o/side"}},"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"},"side":{"target":"C2","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('pushes to tracking remote', function() {
|
||||
expectTreeAsync(
|
||||
'git branch side; git clone;git commit;git push; go side; git commit; git push',
|
||||
'{"branches":{"master":{"target":"C2","id":"master"},"side":{"target":"C3","id":"side"},"o/master":{"target":"C2","id":"o/master"},"o/side":{"target":"C3","id":"o/side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"}},"HEAD":{"target":"side","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master"},"side":{"target":"C3","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -11,7 +11,17 @@ var crappyUnescape = function(str) {
|
|||
return str.replace(/'/g, "'").replace(///g, "/");
|
||||
};
|
||||
|
||||
var ensureBranchIsRemoteTracking = function(engine, branchName) {
|
||||
var assertOriginSpecified = function(generalArgs) {
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var assertBranchIsRemoteTracking = function(engine, branchName) {
|
||||
branchName = crappyUnescape(branchName);
|
||||
if (!engine.refs[branchName]) {
|
||||
throw new GitError({
|
||||
|
@ -147,37 +157,28 @@ var commandConfig = {
|
|||
// so lets switch on A/B here
|
||||
|
||||
var commandOptions = command.getOptionsMap();
|
||||
var options = {
|
||||
isRebase: commandOptions['--rebase']
|
||||
};
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
var tracking;
|
||||
if (generalArgs[1]) {
|
||||
tracking = ensureBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
options.source = tracking;
|
||||
tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
} else {
|
||||
// cant be detached
|
||||
if (engine.getDetachedHead()) {
|
||||
throw new GitError({
|
||||
msg: intl.todo('Git pull can not be executed in detached HEAD mode!')
|
||||
msg: intl.todo('Git pull can not be executed in detached HEAD mode if no remote branch specified!')
|
||||
});
|
||||
}
|
||||
var oneBefore = engine.getOneBeforeCommit('HEAD');
|
||||
tracking = ensureBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
options.source = tracking;
|
||||
tracking = assertBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
}
|
||||
|
||||
engine.pull(options);
|
||||
engine.pull({
|
||||
source: tracking,
|
||||
isRebase: commandOptions['--rebase']
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -249,16 +250,10 @@ var commandConfig = {
|
|||
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
if (generalArgs[0] !== 'origin') {
|
||||
throw new GitError({
|
||||
msg: intl.todo(
|
||||
generalArgs[0] + ' is not a remote in your repository! try origin'
|
||||
)
|
||||
});
|
||||
}
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
if (generalArgs[1]) {
|
||||
var tracking = ensureBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
var tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
options.branches = [engine.refs[tracking]];
|
||||
}
|
||||
|
||||
|
@ -541,8 +536,26 @@ var commandConfig = {
|
|||
msg: intl.str('git-error-origin-required')
|
||||
});
|
||||
}
|
||||
command.acceptNoGeneralArgs();
|
||||
engine.push();
|
||||
|
||||
var options = {};
|
||||
// git push is pretty complex in terms of
|
||||
// the arguments it wants as well -- see
|
||||
// git pull for a more detailed description.
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
command.twoArgsImpliedOrigin(generalArgs);
|
||||
assertOriginSpecified(generalArgs);
|
||||
|
||||
var tracking;
|
||||
if (generalArgs[1]) {
|
||||
tracking = assertBranchIsRemoteTracking(engine, generalArgs[1]);
|
||||
} else {
|
||||
var oneBefore = engine.getOneBeforeCommit('HEAD');
|
||||
tracking = assertBranchIsRemoteTracking(engine, oneBefore.get('id'));
|
||||
}
|
||||
|
||||
engine.push({
|
||||
destination: tracking
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -861,14 +861,15 @@ GitEngine.prototype.descendSortDepth = function(objects) {
|
|||
|
||||
GitEngine.prototype.push = function(options) {
|
||||
options = options || {};
|
||||
var localBranch = this.refs['master'];
|
||||
var remoteBranch = this.origin.refs['master'];
|
||||
var localBranch = this.getOneBeforeCommit('HEAD');
|
||||
var remoteBranch = this.refs[options.destination];
|
||||
var branchOnRemote = this.origin.refs[remoteBranch.getBaseID()];
|
||||
|
||||
// first check if this is even allowed by checking the sync between
|
||||
this.checkUpstreamOfSource(
|
||||
this,
|
||||
this.origin,
|
||||
remoteBranch,
|
||||
branchOnRemote,
|
||||
localBranch,
|
||||
intl.str('git-error-origin-push-no-ff')
|
||||
);
|
||||
|
@ -876,7 +877,7 @@ GitEngine.prototype.push = function(options) {
|
|||
var commitsToMake = this.getTargetGraphDifference(
|
||||
this.origin,
|
||||
this,
|
||||
remoteBranch,
|
||||
branchOnRemote,
|
||||
localBranch
|
||||
);
|
||||
|
||||
|
@ -913,7 +914,7 @@ GitEngine.prototype.push = function(options) {
|
|||
chain = chain.then(_.bind(function() {
|
||||
return this.animationFactory.playHighlightPromiseAnimation(
|
||||
this.refs[commitJSON.id],
|
||||
remoteBranch
|
||||
branchOnRemote
|
||||
);
|
||||
}, this));
|
||||
|
||||
|
@ -928,7 +929,7 @@ GitEngine.prototype.push = function(options) {
|
|||
chain = chain.then(_.bind(function() {
|
||||
var localLocationID = localBranch.get('target').get('id');
|
||||
var remoteCommit = this.origin.refs[localLocationID];
|
||||
this.origin.setTargetLocation(remoteBranch, remoteCommit);
|
||||
this.origin.setTargetLocation(branchOnRemote, remoteCommit);
|
||||
// unhighlight local
|
||||
this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
return this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
|
||||
|
@ -937,9 +938,7 @@ GitEngine.prototype.push = function(options) {
|
|||
// HAX HAX update master and remote tracking for master
|
||||
chain = chain.then(_.bind(function() {
|
||||
var localCommit = this.getCommitFromRef(localBranch);
|
||||
var remoteBranchID = localBranch.getRemoteTrackingBranchID();
|
||||
// less hacks hax
|
||||
this.setTargetLocation(this.refs[remoteBranchID], localCommit);
|
||||
this.setTargetLocation(remoteBranch, localCommit);
|
||||
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
|
||||
}, this));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue