cros flash: read latest link to resolve a revision

BUG=chromium:899801
TEST=precq

Change-Id: Ice26b19ff0b99aa1d4a8cdb1cf4987cc3d025f3f
Reviewed-on: https://chromium-review.googlesource.com/1308313
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/xbuddy.py b/xbuddy.py
index 0bb5c99..d575d9a 100644
--- a/xbuddy.py
+++ b/xbuddy.py
@@ -572,13 +572,13 @@
       XBuddyException if neither test nor dev image was found in latest built
       directory.
     """
-    latest_local_dir = self.GetLatestImageDir(board)
+    latest_local_dir = self.GetLatestImageLink(board)
     if not latest_local_dir or not os.path.exists(latest_local_dir):
       raise XBuddyException('No builds found for %s. Did you run build_image?' %
                             board)
 
     # Assume that the version number is the name of the directory.
-    return os.path.basename(latest_local_dir.rstrip('/'))
+    return os.path.basename(os.path.realpath(latest_local_dir))
 
   @staticmethod
   def _FindAny(local_dir):
@@ -810,8 +810,8 @@
         order of stability.
 
     Raises:
-        build_artifact.ArtifactDownloadError: If we failed to download the
-                                              artifact.
+      build_artifact.ArtifactDownloadError: If we failed to download the
+        artifact.
     """
     # Stage image if not found in cache.
     file_name = GS_ALIAS_TO_FILENAME[image_type]