[infra] Modify 2.7.0 make_version hack so that it also works on other branches

The logic only worked on the 'be' branch but if Flutter uses a dev branch hash
they would get a dev release version rather than the hardcoded 2.7.0 version.

Change-Id: I6be3b3a115a10dfb6e2a6d1407d27f96c6d88396
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126823
Reviewed-by: Siva Annamalai <asiva@google.com>
diff --git a/tools/make_version.py b/tools/make_version.py
index 70f2900..4b16d91 100755
--- a/tools/make_version.py
+++ b/tools/make_version.py
@@ -47,6 +47,18 @@
 
 def MakeVersionString(quiet, no_git_hash, custom_for_pub=None):
     channel = utils.GetChannel()
+    if custom_for_pub:
+        # TODO(athom): remove the custom 2.7.0 logic post release.
+        # For 2.7.0, we want flutter to claim Dart is 2.7.0 even before it is
+        # decided what exactly 2.7.0 will be. Dart & Flutter stable releases
+        # will be synced, so that what will be released as Dart 2.7.0 will also
+        # be what will be packaged with Flutter.
+        version = utils.ReadVersionFile()
+        custom_version_string = "%s.%s.%s" % (version.major, version.minor,
+                                              version.patch)
+        if custom_version_string == "2.7.0" and custom_for_pub == "flutter":
+            return "2.7.0"
+
     if custom_for_pub and channel == 'be':
         latest = utils.GetLatestDevTag()
         if not latest:
@@ -57,16 +69,6 @@
         else:
             git_hash = utils.GetShortGitHash()
             version_string = ("%s.%s-%s" % (latest, custom_for_pub, git_hash))
-        # TODO(athom): remove the custom 2.7.0 logic post release.
-        # For 2.7.0, we want flutter to claim Dart is 2.7.0 even before it is
-        # decided what exactly 2.7.0 will be. Dart & Flutter stable releases
-        # will be synced, so that what will be released as Dart 2.7.0 will also
-        # be what will be packaged with Flutter.
-        version = utils.ReadVersionFile()
-        custom_version_string = "%s.%s.%s" % (version.major, version.minor, version.patch)
-        if custom_version_string == "2.7.0" and custom_for_pub == "flutter":
-            version_string = "2.7.0"
-
     else:
         version_string = utils.GetSemanticSDKVersion(no_git_hash=no_git_hash)
     if not quiet: