txt_roller: Move txt-specific parts to func

No functional changes.

Bug: b/341756093
Change-Id: Iaf57f7c1db76da4313f4b5ee00f959ae9a032cad
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/230652
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: Oliver Newman <olivernewman@google.com>
diff --git a/recipes/txt_roller.py b/recipes/txt_roller.py
index 90ea53d..f4f4efe 100644
--- a/recipes/txt_roller.py
+++ b/recipes/txt_roller.py
@@ -29,6 +29,7 @@
 if TYPE_CHECKING:  # pragma: no cover
     from typing import Generator
     from recipe_engine import recipe_api, recipe_test_api
+    from RECIPE_MODULES.pigweed.checkout import api as checkout_api
 
 DEPS = [
     'fuchsia/auto_roller',
@@ -44,21 +45,14 @@
 PROPERTIES = InputProperties
 
 
-def RunSteps(  # pylint: disable=invalid-name
+def _update_txt_file(
     api: recipe_api.RecipeScriptApi,
-    props: InputProperties,
-):
-    txt_path: str = props.txt_path
-    project_remote: str = props.project_remote
-    project_branch: str = props.project_branch or 'main'
-
-    # The checkout module will try to use trigger data to pull in a specific
-    # patch. Since the triggering commit is in a different repository that
-    # needs to be disabled.
-    props.checkout_options.use_trigger = False
-    checkout: api.checkout.CheckoutContext = api.checkout(
-        props.checkout_options
-    )
+    checkout: checkout_api.CheckoutContext,
+    txt_path: str,
+    project_remote: str,
+    project_branch: str | None,
+) -> dict[str, api.roll_util.Roll] | None:
+    project_branch = project_branch or 'main'
 
     new_revision: Optional[str] = None
 
@@ -131,7 +125,7 @@
     with api.step.nest('txt_path') as pres:
         pres.step_summary_text = repr(txt_path)
 
-    rolls: dict[str, api.roll_util.Roll] = {
+    return {
         txt_path: api.roll_util.create_roll(
             project_name=txt_path,
             old_revision=old_revision,
@@ -141,6 +135,29 @@
         ),
     }
 
+
+def RunSteps(  # pylint: disable=invalid-name
+    api: recipe_api.RecipeScriptApi,
+    props: InputProperties,
+):
+    # The checkout module will try to use trigger data to pull in a specific
+    # patch. Since the triggering commit is in a different repository that
+    # needs to be disabled.
+    props.checkout_options.use_trigger = False
+    checkout: api.checkout.CheckoutContext = api.checkout(
+        props.checkout_options
+    )
+
+    rolls = _update_txt_file(
+        api=api,
+        checkout=checkout,
+        txt_path=props.txt_path,
+        project_remote=props.project_remote,
+        project_branch=props.project_branch,
+    )
+    if not rolls:
+        return
+
     authors: Sequence[api.roll_util.Account] = api.roll_util.authors(
         *rolls.values()
     )