From 85955e7413a3a63d5bd8dcc04a284ad081b3c38d Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Sat, 26 Apr 2025 12:56:25 -0400 Subject: [PATCH 1/2] My attempt at #1245 --- src/js/git/index.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/js/git/index.js b/src/js/git/index.js index b8aba3cb..0414c374 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -2412,6 +2412,16 @@ GitEngine.prototype.rebaseFinish = function( var destinationBranch = this.resolveID(targetSource); var deferred = options.deferred || Q.defer(); var chain = options.chain || deferred.promise; + var originalCurrentLocationToUpdate = null; + if (this.getType(currentLocation) == 'commit') { + // We will just be updating HEAD so no need to store + // anything + } else { + // This is the source branch we are coming off of, so we need + // to update this bad boy after the animation + originalCurrentLocationToUpdate = this.getOneBeforeCommit(currentLocation); + } + debugger; var toRebase = this.filterRebaseCommits(toRebaseRough, stopSet, options); if (!toRebase.length) { @@ -2426,6 +2436,13 @@ GitEngine.prototype.rebaseFinish = function( destinationBranch ); + chain = chain.then(function() { + // Animate our current location to the base to aid + // in visual learning + this.checkout(this.getCommitFromRef(targetSource)); + return this.animationFactory.playRefreshAnimation(this.gitVisuals); + }.bind(this)); + // now pop all of these commits onto targetLocation var base = this.getCommitFromRef(targetSource); var hasStartedChain = false; @@ -2461,15 +2478,15 @@ GitEngine.prototype.rebaseFinish = function( }); }, this); + // now base will be the last commit in the chain, so we need to set the + // source to that commit chain = chain.then(function() { - if (this.resolveID(currentLocation).get('type') == 'commit') { - // we referenced a commit like git rebase C2 C1, so we have - // to manually check out C1' - this.checkout(base); + if (originalCurrentLocationToUpdate) { + console.log('in this branch'); + this.setTargetLocation(originalCurrentLocationToUpdate, base); + this.checkout(originalCurrentLocationToUpdate); } else { - // now we just need to update the rebased branch is - this.setTargetLocation(currentLocation, base); - this.checkout(currentLocation); + this.checkout(base); } return this.animationFactory.playRefreshAnimation(this.gitVisuals); }.bind(this)); @@ -2520,7 +2537,7 @@ GitEngine.prototype.merge = function(targetSource, options) { // since we specify parent 1 as the first parent, it is the "main" parent // and the node will be displayed below that branch / commit / whatever var commitParents = [parent1]; - + if (!options.squash) { // a squash commit doesn't include the reference to the second parent commitParents.push(parent2); From b76e4a4501dc546fe2f5672369dcc881fd566d05 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Sat, 26 Apr 2025 12:57:09 -0400 Subject: [PATCH 2/2] remove some debug stuff --- src/js/git/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/js/git/index.js b/src/js/git/index.js index 0414c374..291a5242 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -2421,7 +2421,6 @@ GitEngine.prototype.rebaseFinish = function( // to update this bad boy after the animation originalCurrentLocationToUpdate = this.getOneBeforeCommit(currentLocation); } - debugger; var toRebase = this.filterRebaseCommits(toRebaseRough, stopSet, options); if (!toRebase.length) { @@ -2482,7 +2481,6 @@ GitEngine.prototype.rebaseFinish = function( // source to that commit chain = chain.then(function() { if (originalCurrentLocationToUpdate) { - console.log('in this branch'); this.setTargetLocation(originalCurrentLocationToUpdate, base); this.checkout(originalCurrentLocationToUpdate); } else {