[ci_yaml] Roll to branch HEAD

* Prevent issues with the rolls coming out of sync

Bug: https://github.com/flutter/flutter/issues/112127
Change-Id: I3d6c8fc581987914753681693639284f0e163ea5
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/50200
Commit-Queue: Casey Hillers <chillers@google.com>
Reviewed-by: Godofredo Contreras <godofredoc@google.com>
diff --git a/recipes/infra/ci_yaml.expected/basic.json b/recipes/infra/ci_yaml.expected/basic.json
index 3a81c94..47db2d2 100644
--- a/recipes/infra/ci_yaml.expected/basic.json
+++ b/recipes/infra/ci_yaml.expected/basic.json
@@ -728,7 +728,7 @@
       "dart",
       "[START_DIR]/cocoon/app_dart/bin/generate_jspb.dart",
       "engine",
-      "abc123"
+      "main"
     ],
     "cwd": "[START_DIR]/cocoon/app_dart",
     "env": {
diff --git a/recipes/infra/ci_yaml.expected/release.json b/recipes/infra/ci_yaml.expected/release.json
index 8f8b5a7..896ce09 100644
--- a/recipes/infra/ci_yaml.expected/release.json
+++ b/recipes/infra/ci_yaml.expected/release.json
@@ -728,7 +728,7 @@
       "dart",
       "[START_DIR]/cocoon/app_dart/bin/generate_jspb.dart",
       "engine",
-      "abc123"
+      "dev"
     ],
     "cwd": "[START_DIR]/cocoon/app_dart",
     "env": {
diff --git a/recipes/infra/ci_yaml.expected/staging.json b/recipes/infra/ci_yaml.expected/staging.json
index 5e09a5f..ac899b6 100644
--- a/recipes/infra/ci_yaml.expected/staging.json
+++ b/recipes/infra/ci_yaml.expected/staging.json
@@ -728,7 +728,7 @@
       "dart",
       "[START_DIR]/cocoon/app_dart/bin/generate_jspb.dart",
       "engine",
-      "abc123"
+      "main"
     ],
     "cwd": "[START_DIR]/cocoon/app_dart",
     "env": {
diff --git a/recipes/infra/ci_yaml.py b/recipes/infra/ci_yaml.py
index bc40308..7f293a3 100644
--- a/recipes/infra/ci_yaml.py
+++ b/recipes/infra/ci_yaml.py
@@ -56,11 +56,11 @@
       )
   )
 
-  git_branch = api.properties.get('git_branch')
+  git_branch = api.properties.get('git_branch', 'main')
   repo = api.properties.get('git_repo')
   if _is_postsubmit(api):
-    # gitiles commit info
-    git_ref = api.buildbucket.gitiles_commit.id
+    # Pulling from HEAD ensures out of order runs do not lead to inconsistencies.
+    git_ref = git_branch
   else:
     # github pull request info
     git_ref = 'main'  # Default to master for LED runs
@@ -83,7 +83,7 @@
     infra_config_path = infra_path.join(
         'config', 'generated', 'ci_yaml', config_name
     )
-   # Generate_jspb
+    # Generate_jspb
     jspb_step = api.step(
         'generate jspb',
         cmd=['dart', generate_jspb_path, repo, git_ref],
@@ -123,7 +123,8 @@
               bot_commit=True,
           ),
           repo_dir=infra_path,
-          commit_message='Roll %s to %s' % (repo, git_ref),
+          commit_message='Roll %s to %s' %
+          (repo, api.buildbucket.gitiles_commit.id),
       )