mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-25 15:38:33 +02:00
correctness on fetch
This commit is contained in:
parent
7cec1bcaab
commit
9840a5e6b4
5 changed files with 96 additions and 53 deletions
|
@ -787,19 +787,26 @@ GitEngine.prototype.getTargetGraphDifference = function(
|
|||
}
|
||||
|
||||
// filter because we werent doing graph search
|
||||
var differenceUnique = this.getUniqueObjects(difference);
|
||||
return this.descendSortDepth(differenceUnique);
|
||||
};
|
||||
|
||||
GitEngine.prototype.getUniqueObjects = function(objects) {
|
||||
var unique = {};
|
||||
var differenceUnique = [];
|
||||
_.forEach(difference, function(commit) {
|
||||
if (unique[commit.id]) {
|
||||
var result = [];
|
||||
_.forEach(objects, function(object) {
|
||||
if (unique[object.id]) {
|
||||
return;
|
||||
}
|
||||
unique[commit.id] = true;
|
||||
differenceUnique.push(commit);
|
||||
unique[object.id] = true;
|
||||
result.push(object);
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
return differenceUnique.sort(function(cA, cB) {
|
||||
// reverse sort by depth
|
||||
return cB.depth - cA.depth;
|
||||
GitEngine.prototype.descendSortDepth = function(objects) {
|
||||
return objects.sort(function(oA, oB) {
|
||||
return oB.depth - oA.depth;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -913,8 +920,7 @@ GitEngine.prototype.fetch = function(options) {
|
|||
);
|
||||
}, this);
|
||||
|
||||
// then we get the difference in commits between these two graphs, ordered by
|
||||
// depth. TODO -- make work for all branches
|
||||
// then we get the difference in commits between these two graphs
|
||||
var commitsToMake = [];
|
||||
_.each(allRemotes, function(localRemoteBranch) {
|
||||
commitsToMake = commitsToMake.concat(this.getTargetGraphDifference(
|
||||
|
@ -925,6 +931,12 @@ GitEngine.prototype.fetch = function(options) {
|
|||
options
|
||||
));
|
||||
}, this);
|
||||
// we did this for each remote branch, but we still need to reduce to unique
|
||||
// and sort. in this particular app we can never have unfected remote
|
||||
// commits that are upstream of multiple branches (since the fakeTeamwork
|
||||
// command simply commits), but we are doing it anyways for correctness
|
||||
commitsToMake = this.getUniqueObjects(commitsToMake);
|
||||
commitsToMake = this.descendSortDepth(commitsToMake);
|
||||
|
||||
if (commitsToMake.length === 0) {
|
||||
this.command.addWarning(intl.str(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue