build-unit-test-docker: ensure we stop on first branch

Ran into an issue where we were creating our root branch (i.e. 1110) and
then creating some snapshot branches (i.e. 1110-snapshot-xyz). The
script would end up using that snapshot branch.

Lots of potential discussion to be had on our branch creations decisions
but either way, best to make sure we match with the exact branch
being passed in.

Tested:
- Confirmed over in ibm-openbmc/openbmc that we pick up expected
  branches now.

Change-Id: I71099f42ca40bfd9fe719a550349eba82000133d
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index 7bc1157..e3650ab 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -21,6 +21,7 @@
 #                     Default: "", proxy is not setup if this is not set
 
 import os
+import re
 import sys
 import threading
 from datetime import date
@@ -433,8 +434,9 @@
         #   This section is locked because we are modifying the PackageDef.
         Package.lock.acquire()
         for line in lookup.split("\n"):
-            if f"refs/heads/{branch}" in line:
+            if re.fullmatch(f".*{branch}$", line.strip()):
                 self.pkg_def["rev"] = line.split()[0]
+                break
             elif (
                 "refs/heads/master" in line or "refs/heads/main" in line
             ) and "rev" not in self.pkg_def: