Skip to content

Commit 7c461d9

Browse files
authored
Merge pull request #44 from Ensembl/make-prf-uptodate
Keep postreleasefix branch uptodate during mpush
2 parents 9781004 + 62e3670 commit 7c461d9

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

bin/git-mpush

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,16 @@ sub run {
147147

148148
# If both branches have unpushed commits, we don't try to be over-intelligent and move commits around - leave that on to the user
149149
if (keys %$branch_with_commits == 2) {
150-
error("Both '$master_branch' and '$release_branch' branches have commits to push. Please move these commits to one branch before you continue.");
150+
error("Both '$master_branch' and '$release_branch' branches have commits to push. Please move these commits to release branch before you continue.");
151151
}
152152

153153
# save pointers to the slower and the faster branch
154154
my ($slower_branch, $faster_branch) = sort { exists $branch_with_commits->{$a} ? 1 : -1 } $master_branch, $release_branch;
155155

156+
156157
# If remote branches are actually at same point (and user doesn't mind fast-forwarding), fast-forward the slower local branch to the other
157-
if (!$options->{'no-ff'} && rev_parse("$remote/$release_branch") eq rev_parse("$remote/$master_branch")) {
158+
if (!$options->{'no-ff'} && rev_parse("$remote/$release_branch") eq rev_parse("$remote/$post_release_fix_branch")
159+
&& rev_parse("$remote/$release_branch") eq rev_parse("$remote/$master_branch") ) {
158160

159161
# checkout the slower branch
160162
switch_branch($slower_branch);
@@ -165,11 +167,20 @@ sub run {
165167
error("Could not fast-forward branch '$slower_branch' to '$faster_branch'.");
166168
}
167169

168-
info("Local branches '$master_branch' and '$release_branch' are at the same point now.");
170+
# checkout the postreleasefix branch to do a fast-forward merge so that all 3 branches are up to date with latest commits
171+
switch_branch($post_release_fix_branch);
172+
173+
# fast-forward merge the faster branch to the slower one
174+
info("Attempting to fast-forward branch '$post_release_fix_branch' to '$faster_branch'");
175+
if (!ff_merge($faster_branch)) {
176+
error("Could not fast-forward branch '$post_release_fix_branch' to '$faster_branch'.");
177+
}
178+
179+
info("Local branches '$master_branch', '$release_branch' and '$post_release_fix_branch' are at the same point now.");
169180

170-
# Finally push both branches
181+
# Finally push both
171182
my $failed_push = {};
172-
for ($master_branch, $release_branch) {
183+
for ($master_branch, $release_branch, $post_release_fix_branch) {
173184
if (!push_branch($remote, $_, $options->{'no-push'})) {
174185
$failed_push->{$_} = 1;
175186
}
@@ -182,7 +193,7 @@ sub run {
182193
error(join "\n", 'Following branch(es) could not be push to remote:', keys %$failed_push);
183194
} else {
184195
if (@{$branch_with_commits->{$faster_branch} || []}) {
185-
info(join "\n", 'DONE: Successfully updated both branches with following commit(s):', @{$branch_with_commits->{$faster_branch}});
196+
info(join "\n", 'DONE: Successfully updated 3 branches with following commit(s):', @{$branch_with_commits->{$faster_branch}});
186197
} else {
187198
info("DONE: Nothing to push");
188199
}
@@ -225,6 +236,7 @@ sub run {
225236

226237
# Graft the temp branch on the shared branch
227238
info("Grafting new commits to branch '$temp_branch'.");
239+
info("Command run: git rebase --onto $shared_branch $remote/$faster_branch $temp_branch");
228240
if (!cmd_ok("git rebase --onto $shared_branch $remote/$faster_branch $temp_branch")) {
229241
info("Action failed, cleaning up");
230242
cmd("git rebase --abort");

0 commit comments

Comments
 (0)