-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR unexpectedly merged when commits are reordered #23
Comments
Yes, unfortunately, this is a known bug. The way we should fix it is to get ghstack to stop setting up merge parents between the various PRs it creates (so there is no chance of accidentally closing in this way), but I haven't had time to do it. |
@ezyang do you have an idea of how involved the fix will be? If it's reasonably simple I'd be happy to take it on! |
It's a little hard to say. Essentially, the problem is that |
This diff might be a start but it needs more careful testing diff --git a/ghstack/submit.py b/ghstack/submit.py
index 94f67e6..f6264b5 100644
--- a/ghstack/submit.py
+++ b/ghstack/submit.py
@@ -781,38 +781,19 @@ Since we cannot proceed, ghstack will abort now.
base_args = ()
else:
- # Second, check if our local base (self.base_commit)
- # added some new commits, but is still rooted on the
- # old base.
- #
- # If so, all we need to do is include the local base
- # as a parent when we do the merge.
- is_ancestor = self.sh.git(
- "merge-base",
- "--is-ancestor",
+ # Make a fake commit that
+ # "resets" the tree back to something that makes
+ # sense and merge with that. This doesn't fix
+ # the fact that we still incorrectly report
+ # the old base as an ancestor of our commit, but
+ # it's better than nothing.
+ new_base = GitCommitHash(self.sh.git(
+ "commit-tree", self.base_tree,
+ "-p",
self.remote_name + "/" + branch_base(self.username, ghnum),
- self.base_commit, exitcode=True)
-
- if is_ancestor:
- new_base = self.base_commit
-
- else:
- # If we've gotten here, it means that the new
- # base and the old base are completely
- # unrelated. We'll make a fake commit that
- # "resets" the tree back to something that makes
- # sense and merge with that. This doesn't fix
- # the fact that we still incorrectly report
- # the old base as an ancestor of our commit, but
- # it's better than nothing.
- new_base = GitCommitHash(self.sh.git(
- "commit-tree", self.base_tree,
- "-p",
- self.remote_name + "/" + branch_base(self.username, ghnum),
- "-p", self.base_commit,
- input='Update base for {} on "{}"\n\n{}\n\n[ghstack-poisoned]'
- .format(self.msg, elab_commit.title,
- non_orig_commit_msg)))
+ input='Update base for {} on "{}"\n\n{}\n\n[ghstack-poisoned]'
+ .format(self.msg, elab_commit.title,
+ non_orig_commit_msg)))
base_args = ("-p", new_base) |
I had a stack of 4 PRs, like this:
PR A
PR B
PR C
PR D
PR A
was taking a while to review, so I rebased my stack to put it at the end:PR B
PR C
PR D
PR A
But for some reason, after I ran
ghstack
,PR A
got merged (!)At first I thought I misclicked, but this is the second time it's happened to me.
Log
The text was updated successfully, but these errors were encountered: