mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
Finally fixed async git dispatching and promise chains, fixed rebase level Issue #111
This commit is contained in:
parent
380bcfaa4b
commit
a95a56241b
6 changed files with 25 additions and 24 deletions
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
|
@ -434,7 +434,7 @@
|
|||
For a much easier time perusing the source, see the individual files at:
|
||||
https://github.com/pcottle/learnGitBranching
|
||||
-->
|
||||
<script src="build/bundle.min.421f004f.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
|
||||
|
|
|
@ -24,12 +24,6 @@ var compareAnswerExpect = function(headless, expectedJSON) {
|
|||
expect(equal).toBe(true);
|
||||
};
|
||||
|
||||
var expectTree = function(command, expectedJSON) {
|
||||
var headless = new HeadlessGit();
|
||||
headless.sendCommand(command);
|
||||
compareAnswerExpect(headless, expectedJSON);
|
||||
};
|
||||
|
||||
var expectTreeAsync = function(command, expectedJSON) {
|
||||
var headless = new HeadlessGit();
|
||||
runs(function() {
|
||||
|
@ -42,14 +36,14 @@ var expectTreeAsync = function(command, expectedJSON) {
|
|||
|
||||
describe('GitEngine', function() {
|
||||
it('Commits', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'git commit',
|
||||
'{"branches":{"master":{"target":"C2","id":"master","type":"branch"}},"commits":{"C0":{"type":"commit","parents":[],"id":"C0","rootCommit":true},"C1":{"type":"commit","parents":["C0"],"id":"C1"},"C2":{"type":"commit","parents":["C1"],"id":"C2"}},"HEAD":{"id":"HEAD","target":"master","type":"general ref"}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('Checkouts', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'git checkout -b side',
|
||||
'{"branches":{"master":{"target":"C1","id":"master"},"side":{"target":"C1","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"side","id":"HEAD"}}'
|
||||
);
|
||||
|
@ -70,35 +64,35 @@ describe('GitEngine', function() {
|
|||
});
|
||||
|
||||
it('Merges', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'gc; git checkout -b side C1; gc; git merge master',
|
||||
'{"branches":{"master":{"target":"C2","id":"master"},"side":{"target":"C4","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"},"C4":{"parents":["C2","C3"],"id":"C4"}},"HEAD":{"target":"side","id":"HEAD"}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('Resets', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'git commit; git reset HEAD~1',
|
||||
'{"branches":{"master":{"target":"C1","id":"master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('Branches', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'git branch side C0',
|
||||
'{"branches":{"master":{"target":"C1","id":"master"},"side":{"target":"C0","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('Deletes branches', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'git branch side; git branch -d side',
|
||||
'{"branches":{"master":{"target":"C1","id":"master"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('Ammends commits', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'git commit --amend',
|
||||
'%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C1%27%22%2C%22id%22%3A%22master%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%22C1%27%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%27%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22master%22%2C%22id%22%3A%22HEAD%22%7D%7D'
|
||||
);
|
||||
|
@ -112,7 +106,7 @@ describe('GitEngine', function() {
|
|||
});
|
||||
|
||||
it('Forces branches', function() {
|
||||
expectTree(
|
||||
expectTreeAsync(
|
||||
'git checkout -b side; git branch -f side C0',
|
||||
'{"branches":{"master":{"target":"C1","id":"master"},"side":{"target":"C0","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"side","id":"HEAD"}}'
|
||||
);
|
||||
|
@ -125,5 +119,11 @@ describe('GitEngine', function() {
|
|||
);
|
||||
});
|
||||
|
||||
it('checks out after a rebase', function() {
|
||||
expectTreeAsync(
|
||||
'git commit; git checkout -b bugFix C1; git commit; git rebase master;git checkout master',
|
||||
'%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C2%22%2C%22id%22%3A%22master%22%7D%2C%22bugFix%22%3A%7B%22target%22%3A%22C3%27%22%2C%22id%22%3A%22bugFix%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%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%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%7D'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -83,12 +83,15 @@ HeadlessGit.prototype.sendCommand = function(value, entireCommandPromise) {
|
|||
var startTime = new Date().getTime();
|
||||
|
||||
util.splitTextCommand(value, function(commandStr) {
|
||||
var commandObj = new Command({
|
||||
rawStr: commandStr
|
||||
});
|
||||
var thisDeferred = Q.defer();
|
||||
this.gitEngine.dispatch(commandObj, thisDeferred);
|
||||
chain = chain.then(thisDeferred.promise);
|
||||
chain = chain.then(_.bind(function() {
|
||||
var commandObj = new Command({
|
||||
rawStr: commandStr
|
||||
});
|
||||
|
||||
var thisDeferred = Q.defer();
|
||||
this.gitEngine.dispatch(commandObj, thisDeferred);
|
||||
return thisDeferred.promise;
|
||||
}, this));
|
||||
}, this);
|
||||
|
||||
chain.then(function() {
|
||||
|
|
|
@ -1144,7 +1144,7 @@ GitEngine.prototype.fakeTeamworkStarter = function() {
|
|||
this.validateArgBounds(this.generalArgs, 0, 2);
|
||||
// allow formats of: git Faketeamwork 2 or git Faketeamwork side 3
|
||||
var branch = (this.origin.refs[this.generalArgs[0]]) ?
|
||||
this.generalArgs[0] || 'master';
|
||||
this.generalArgs[0] : 'master';
|
||||
var numToMake = parseInt(this.generalArgs[0], 10) || this.generalArgs[1] || 1;
|
||||
|
||||
// make sure its a branch and exists
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue