Honor the LUCI_BRANCH overrides for release candidate branches.

This is to prevent setting back LUCI_BRANCH=flutter-* before the
documentation generation is triggered.

Bug: https://github.com/flutter/flutter/issues/117157
Change-Id: I11f9e3890aa7e13fa7070eaf603fcb808905d1a9
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/37621
Reviewed-by: Yusuf Mohsinally <mohsinally@google.com>
Commit-Queue: Godofredo Contreras <godofredoc@google.com>
(cherry picked from commit 1b027ba8b8e535d7d42f2685be4fc9fc3807e570)
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/37680
diff --git a/recipe_modules/adhoc_validation/api.py b/recipe_modules/adhoc_validation/api.py
index 7ca0fd9..0d05394 100644
--- a/recipe_modules/adhoc_validation/api.py
+++ b/recipe_modules/adhoc_validation/api.py
@@ -64,6 +64,9 @@
               timeout_secs=4500 # 75 minutes
             )
       else:
+        git_ref = self.m.properties.get('release_ref') or self.m.buildbucket.gitiles_commit.ref
+        # Post-processing of docs require LUCI_BRANCH to be set when running from dart-internal.
+        env['LUCI_BRANCH'] = git_ref.replace('refs/heads/', '')
         # Override LUCI_BRANCH for docs and release candidate branches. Docs built from
         # release candidate branches need to be build as stable to ensure they are processed
         # correctly.