mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 23:48:34 +02:00
Resolves #132 -- checking out remote branches sets tracking
This commit is contained in:
parent
c2cab4c12a
commit
b2321dd265
7 changed files with 62 additions and 9 deletions
|
@ -7774,7 +7774,7 @@ GitEngine.prototype.validateAndMakeBranch = function(id, target) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.makeBranch(id, target);
|
return this.makeBranch(id, target);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.makeBranch = function(id, target) {
|
GitEngine.prototype.makeBranch = function(id, target) {
|
||||||
|
@ -9358,7 +9358,20 @@ GitEngine.prototype.forceBranch = function(branchName, where) {
|
||||||
|
|
||||||
GitEngine.prototype.branch = function(name, ref) {
|
GitEngine.prototype.branch = function(name, ref) {
|
||||||
var target = this.getCommitFromRef(ref);
|
var target = this.getCommitFromRef(ref);
|
||||||
this.validateAndMakeBranch(name, target);
|
var newBranch = this.validateAndMakeBranch(name, target);
|
||||||
|
|
||||||
|
ref = this.resolveID(ref);
|
||||||
|
if (this.isRemoteBranchRef(ref)) {
|
||||||
|
this.setLocalToTrackRemote(newBranch, ref);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.isRemoteBranchRef = function(ref) {
|
||||||
|
var resolved = this.resolveID(ref);
|
||||||
|
if (resolved.get('type') !== 'branch') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return resolved.getIsRemote();
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.deleteBranch = function(name) {
|
GitEngine.prototype.deleteBranch = function(name) {
|
||||||
|
@ -27482,7 +27495,7 @@ GitEngine.prototype.validateAndMakeBranch = function(id, target) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.makeBranch(id, target);
|
return this.makeBranch(id, target);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.makeBranch = function(id, target) {
|
GitEngine.prototype.makeBranch = function(id, target) {
|
||||||
|
@ -29066,7 +29079,20 @@ GitEngine.prototype.forceBranch = function(branchName, where) {
|
||||||
|
|
||||||
GitEngine.prototype.branch = function(name, ref) {
|
GitEngine.prototype.branch = function(name, ref) {
|
||||||
var target = this.getCommitFromRef(ref);
|
var target = this.getCommitFromRef(ref);
|
||||||
this.validateAndMakeBranch(name, target);
|
var newBranch = this.validateAndMakeBranch(name, target);
|
||||||
|
|
||||||
|
ref = this.resolveID(ref);
|
||||||
|
if (this.isRemoteBranchRef(ref)) {
|
||||||
|
this.setLocalToTrackRemote(newBranch, ref);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.isRemoteBranchRef = function(ref) {
|
||||||
|
var resolved = this.resolveID(ref);
|
||||||
|
if (resolved.get('type') !== 'branch') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return resolved.getIsRemote();
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.deleteBranch = function(name) {
|
GitEngine.prototype.deleteBranch = function(name) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
1
build/bundle.min.63fdd97d.js
Normal file
1
build/bundle.min.63fdd97d.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:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
-->
|
-->
|
||||||
<script src="build/bundle.min.3d8d2b8e.js"></script>
|
<script src="build/bundle.min.63fdd97d.js"></script>
|
||||||
|
|
||||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
<!-- 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
|
The downside? No raw logs to parse for analytics, so I have to include
|
||||||
|
|
|
@ -113,6 +113,20 @@ describe('Git Remotes', function() {
|
||||||
'{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master","localBranchesThatTrackThis":null},"side":{"target":"C3","id":"side","remoteTrackingBranchID":"o/side","localBranchesThatTrackThis":null},"o/master":{"target":"C2","id":"o/master","remoteTrackingBranchID":null,"localBranchesThatTrackThis":["master"]},"o/side":{"target":"C3","id":"o/side","remoteTrackingBranchID":null,"localBranchesThatTrackThis":["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","remoteTrackingBranchID":null,"localBranchesThatTrackThis":null},"side":{"target":"C3","id":"side","remoteTrackingBranchID":null,"localBranchesThatTrackThis":null}},"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"}}}'
|
'{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master","localBranchesThatTrackThis":null},"side":{"target":"C3","id":"side","remoteTrackingBranchID":"o/side","localBranchesThatTrackThis":null},"o/master":{"target":"C2","id":"o/master","remoteTrackingBranchID":null,"localBranchesThatTrackThis":["master"]},"o/side":{"target":"C3","id":"o/side","remoteTrackingBranchID":null,"localBranchesThatTrackThis":["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","remoteTrackingBranchID":null,"localBranchesThatTrackThis":null},"side":{"target":"C3","id":"side","remoteTrackingBranchID":null,"localBranchesThatTrackThis":null}},"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"}}}'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('sets tracking when checking out remote branch', function() {
|
||||||
|
expectTreeAsync(
|
||||||
|
'git clone; git checkout -b side o/master;git fakeTeamwork;git pull',
|
||||||
|
'{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master","localBranchesThatTrackThis":null},"o/master":{"target":"C2","id":"o/master","remoteTrackingBranchID":null,"localBranchesThatTrackThis":["master","side"]},"side":{"target":"C2","id":"side","remoteTrackingBranchID":"o/master","localBranchesThatTrackThis":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"side","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":null,"localBranchesThatTrackThis":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('also sets tracking when just branching', function() {
|
||||||
|
expectTreeAsync(
|
||||||
|
'git clone; git branch side o/master',
|
||||||
|
'{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":"o/master","localBranchesThatTrackThis":null},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null,"localBranchesThatTrackThis":["master","side"]},"side":{"target":"C1","id":"side","remoteTrackingBranchID":"o/master","localBranchesThatTrackThis":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null,"localBranchesThatTrackThis":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -548,7 +548,7 @@ GitEngine.prototype.validateAndMakeBranch = function(id, target) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.makeBranch(id, target);
|
return this.makeBranch(id, target);
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.makeBranch = function(id, target) {
|
GitEngine.prototype.makeBranch = function(id, target) {
|
||||||
|
@ -2132,7 +2132,20 @@ GitEngine.prototype.forceBranch = function(branchName, where) {
|
||||||
|
|
||||||
GitEngine.prototype.branch = function(name, ref) {
|
GitEngine.prototype.branch = function(name, ref) {
|
||||||
var target = this.getCommitFromRef(ref);
|
var target = this.getCommitFromRef(ref);
|
||||||
this.validateAndMakeBranch(name, target);
|
var newBranch = this.validateAndMakeBranch(name, target);
|
||||||
|
|
||||||
|
ref = this.resolveID(ref);
|
||||||
|
if (this.isRemoteBranchRef(ref)) {
|
||||||
|
this.setLocalToTrackRemote(newBranch, ref);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.isRemoteBranchRef = function(ref) {
|
||||||
|
var resolved = this.resolveID(ref);
|
||||||
|
if (resolved.get('type') !== 'branch') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return resolved.getIsRemote();
|
||||||
};
|
};
|
||||||
|
|
||||||
GitEngine.prototype.deleteBranch = function(name) {
|
GitEngine.prototype.deleteBranch = function(name) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue