[GN]: Fix typo and a bug in the GN roll script.

When complete, the script attempts to switch from the branches it creates
to build and roll things back to the branch you were on before.

The way it determines what branch you were on before is by looking at
git's reflog. However, the way I was looking at the reflog was wrong;
first, it was doing an re.match() instead of an re.search(), and so
it was looking for a match at the beginning of the output (which would
never be true). Second, we were looking at only the most recent entry,
and when the roll script actually executed, the most recent entry would
always be a commit, not a checkout, and so we wouldn't see what the
previous branch was.

BUG=none
R=dpranke@chromium.org

Review URL: https://codereview.chromium.org/1381753003

Cr-Original-Commit-Position: refs/heads/master@{#351613}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: c9ef0df1e21a0e9be8c855fbbf01386ed0617d2a
diff --git a/tools/gn/bin/roll_gn.py b/tools/gn/bin/roll_gn.py
index 1e9dec9..b5c276e 100644
--- a/tools/gn/bin/roll_gn.py
+++ b/tools/gn/bin/roll_gn.py
@@ -199,7 +199,7 @@
     # Close the build CL and move off of the build branch back to whatever
     # we were on before.
     self.Call('git-cl set-close')
-    self.MovetoLastHead()
+    self.MoveToLastHead()
 
     return ret
 
@@ -375,9 +375,12 @@
 
     return 0
 
-  def MovetoLastHead(self):
-    _, out, _ = self.Call('git reflog -1')
-    m = re.match('moving from ([^\s]+)', out)
+  def MoveToLastHead(self):
+    # When this is called, there will be a commit + a checkout as
+    # the two most recent entries in the reflog, assuming nothing as
+    # modified the repo while this script has been running.
+    _, out, _ = self.Call('git reflog -2')
+    m = re.search('moving from ([^\s]+)', out)
     last_head = m.group(1)
     self.Call('git checkout %s' % last_head)