Move git-related functionality out of cros_build_lib (1 of 4).

cros_build_lib is starting to get really long -- it's now 2279 lines. This CL
moves git-related functionality out of cros_build_lib into git.py, reducing the
size and complexity of cros_build_lib by over 980 lines.

Note  CL:*29160 and CL:*29161 should also be committed at the same time as this
CL, but CQ is not capable of handling external -> internal dependencies, so we
leave this dependency as implicit.

BUG=none
CQ-DEPEND=CL:38255
TEST=pylint, regexps, run_tests, and lots of trybot runs.
Change-Id: Id6c749df09862a724bef2eee84ca719ed461589c
Reviewed-on: https://gerrit.chromium.org/gerrit/38253
Commit-Ready: David James <davidjames@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/scripts/loman.py b/scripts/loman.py
index ceedcfe..4f3ad8b 100644
--- a/scripts/loman.py
+++ b/scripts/loman.py
@@ -11,6 +11,7 @@
 import sys
 import xml.etree.ElementTree as ElementTree
 from chromite.lib import cros_build_lib
+from chromite.lib import git
 
 
 class Manifest(object):
@@ -157,7 +158,7 @@
                     "checkout utilizing manifest groups.")
   (options, args) = parser.parse_args(argv)
 
-  repo_dir = cros_build_lib.FindRepoDir()
+  repo_dir = git.FindRepoDir()
   if not repo_dir:
     parser.error("This script must be invoked from within a repository "
                  "checkout.")
@@ -210,9 +211,9 @@
 
   revision = options.revision
   if revision is not None:
-    if (not cros_build_lib.IsRefsTags(revision) and
-        not cros_build_lib.IsSHA1(revision)):
-      revision = cros_build_lib.StripLeadingRefsHeads(revision, False)
+    if (not git.IsRefsTags(revision) and
+        not git.IsSHA1(revision)):
+      revision = git.StripRefsHeads(revision, False)
 
   main_manifest = Manifest.FromPath(options.manifest_sym_path,
                                     empty_if_missing=False)