Răsfoiți Sursa

bot_update: allow rebasing the patch onto an older revision.

When applying a rebase, we normally go from an older base commit to a newer one.

A ---- B ---- C ---- D -origin/master
               \
                E -branch

In this case, `git rebase D` would certainly work as expected. However,
writing `git rebase B` would NOT get us to the following state:

A ---- B ---- C ---- D -origin/master
        \
         E' -branch

In fact, it would have no effect.

This article http://matthew-brett.github.io/pydagogue/rebase_without_tears.html
explains the general invocation as
> `git rebase --onto <graft-point> <exclude-from> <include-from>`
> If you don’t specify --onto, <graft-point> defaults to <exclude-from>

So what's happening is, by writing `git rebase B` we're rebasing onto B,
excluding commits that are in B. Commit C is not "in" B so it is kept and we're
back to the starting point.

So I suggest to change the invocation to `git rebase --onto B origin/master`,
which rebases onto B, excluding commits that are in origin/master. This works
more generally and allows rebasing "backwards".

Bug: None
Change-Id: I68e4d805811530b585550bc75099354fef4e9c15
Reviewed-on: https://chromium-review.googlesource.com/904004
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Oleh Prypin <oprypin@chromium.org>
Oleh Prypin 7 ani în urmă
părinte
comite
fa573785df
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      recipes/recipe_modules/bot_update/resources/bot_update.py

+ 1 - 1
recipes/recipe_modules/bot_update/resources/bot_update.py

@@ -745,7 +745,7 @@ def apply_gerrit_ref(gerrit_repo, gerrit_ref, root, gerrit_reset,
         try:
         try:
           git('-c', 'user.name=chrome-bot',
           git('-c', 'user.name=chrome-bot',
               '-c', 'user.email=chrome-bot@chromium.org',
               '-c', 'user.email=chrome-bot@chromium.org',
-              'rebase', base_rev, cwd=root)
+              'rebase', '--onto', base_rev, 'origin/master', cwd=root)
         except SubprocessFailed:
         except SubprocessFailed:
           # Abort the rebase since there were failures.
           # Abort the rebase since there were failures.
           git('rebase', '--abort', cwd=root)
           git('rebase', '--abort', cwd=root)