style: use import git_refs everywhere

Align with Google style guides and `import git_refs` as a module
rather than import symbols out of it.

Change-Id: I4e33ebdf3b06acd94494f32cdf39aa58427cd4b2
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/648703
Reviewed-by: Brian Gan <brgan@google.com>
Commit-Queue: Mike Frysinger <vapier@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger authored and gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com committed 2026-10-27 02:00:11 -07:00
1 parent 8c316d7c98
commit 338ddb7d83
9 files changed
+144 -129

No files matched your search

+4 -5
View File
@@ -23,8 +23,7 @@ from typing import Any, Dict, List, NamedTuple, Optional, Tuple
from color import Coloring
from command import DEFAULT_LOCAL_JOBS
from command import PagedCommand
from git_refs import R_HEADS
from git_refs import R_M
import git_refs
class BranchInfo(NamedTuple):
@@ -333,9 +332,9 @@ class Info(PagedCommand):
branch = project.manifest.manifestProject.config.GetBranch(
"default"
).merge
if branch.startswith(R_HEADS):
branch = branch[len(R_HEADS) :]
logTarget = R_M + branch
if branch.startswith(git_refs.R_HEADS):
branch = branch[len(git_refs.R_HEADS) :]
logTarget = git_refs.R_M + branch
localCommits, originCommits = cls._GetDiffCommits(
project, logTarget
+7 -5
View File
@@ -62,8 +62,7 @@ import event_log
import git_command
from git_config import GetUrlCookieFile
from git_config import RepoConfig
from git_refs import HEAD
from git_refs import R_HEADS
import git_refs
import git_superproject
from hooks import RepoHook
from manifest_xml import XmlManifest
@@ -866,8 +865,8 @@ later is required to fix a server side protocol bug.
"""
b = manifest_project.GetBranch(manifest_project.CurrentBranch)
branch = b.merge
if branch.startswith(R_HEADS):
branch = branch[len(R_HEADS) :]
if branch.startswith(git_refs.R_HEADS):
branch = branch[len(git_refs.R_HEADS) :]
return branch
@classmethod
@@ -3501,7 +3500,10 @@ def _PostRepoFetch(rp, repo_verify=True, verbose=False):
logger.warning("warning: Skipped upgrade to unverified version")
else:
if verbose:
print("repo version %s is current" % rp.work_git.describe(HEAD))
print(
"repo version %s is current"
% rp.work_git.describe(git_refs.HEAD)
)
class _FetchTimes:
+5 -5
View File
@@ -23,7 +23,7 @@ from command import DEFAULT_LOCAL_JOBS
from command import InteractiveCommand
from editor import Editor
import error
from git_refs import R_HEADS
import git_refs
import git_superproject
from hooks import RepoHook
from project import ReviewableBranch
@@ -607,11 +607,11 @@ Gerrit Code Review: https://www.gerritcodereview.com/
)
full_dest = destination
if not full_dest.startswith(R_HEADS):
full_dest = R_HEADS + full_dest
if not full_dest.startswith(git_refs.R_HEADS):
full_dest = git_refs.R_HEADS + full_dest
full_revision = branch.project.revisionExpr
if not full_revision.startswith(R_HEADS):
full_revision = R_HEADS + full_revision
if not full_revision.startswith(git_refs.R_HEADS):
full_revision = git_refs.R_HEADS + full_revision
# If the merge branch of the local branch is different from
# the project's revision AND destination, this might not be
+4 -4
View File
@@ -19,7 +19,7 @@ from typing import Any, Tuple
from command import Command
from command import MirrorSafeCommand
import git_command
from git_refs import HEAD
import git_refs
from wrapper import Wrapper
@@ -38,15 +38,15 @@ class Version(Command, MirrorSafeCommand):
"""Return repo's describe string and commit date."""
if git_command.git_require((2, 32, 0)):
output = project.bare_git.log(
"-1", "--format=%(describe)%n%cD", HEAD
"-1", "--format=%(describe)%n%cD", git_refs.HEAD
)
description, commit_date = output.rstrip("\n").split("\n", 1)
if description:
return description, commit_date
return (
project.bare_git.describe(HEAD),
project.bare_git.log("-1", "--format=%cD", HEAD),
project.bare_git.describe(git_refs.HEAD),
project.bare_git.log("-1", "--format=%cD", git_refs.HEAD),
)
def Execute(self, opt, args):