mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
project: Use IsId instead of ID_RE.match
Change-Id: I8ca83a034400da0cb97cba41415bfc50858a898b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385857 Tested-by: Sylvain Desodt <sylvain.desodt@gmail.com> Commit-Queue: Sylvain Desodt <sylvain.desodt@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
e9cb391117
commit
56a5a01c65
21
project.py
21
project.py
@ -44,7 +44,6 @@ from git_command import GitCommand
|
|||||||
from git_config import GetSchemeFromUrl
|
from git_config import GetSchemeFromUrl
|
||||||
from git_config import GetUrlCookieFile
|
from git_config import GetUrlCookieFile
|
||||||
from git_config import GitConfig
|
from git_config import GitConfig
|
||||||
from git_config import ID_RE
|
|
||||||
from git_config import IsId
|
from git_config import IsId
|
||||||
from git_refs import GitRefs
|
from git_refs import GitRefs
|
||||||
from git_refs import HEAD
|
from git_refs import HEAD
|
||||||
@ -1354,10 +1353,8 @@ class Project(object):
|
|||||||
remote_fetched = False
|
remote_fetched = False
|
||||||
if not (
|
if not (
|
||||||
optimized_fetch
|
optimized_fetch
|
||||||
and (
|
and IsId(self.revisionExpr)
|
||||||
ID_RE.match(self.revisionExpr)
|
and self._CheckForImmutableRevision()
|
||||||
and self._CheckForImmutableRevision()
|
|
||||||
)
|
|
||||||
):
|
):
|
||||||
remote_fetched = True
|
remote_fetched = True
|
||||||
try:
|
try:
|
||||||
@ -1674,7 +1671,7 @@ class Project(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
branch.remote = self.GetRemote()
|
branch.remote = self.GetRemote()
|
||||||
if not ID_RE.match(self.revisionExpr):
|
if not IsId(self.revisionExpr):
|
||||||
# In case of manifest sync the revisionExpr might be a SHA1.
|
# In case of manifest sync the revisionExpr might be a SHA1.
|
||||||
branch.merge = self.revisionExpr
|
branch.merge = self.revisionExpr
|
||||||
if not branch.merge.startswith("refs/"):
|
if not branch.merge.startswith("refs/"):
|
||||||
@ -1924,9 +1921,7 @@ class Project(object):
|
|||||||
branch = self.GetBranch(name)
|
branch = self.GetBranch(name)
|
||||||
branch.remote = self.GetRemote()
|
branch.remote = self.GetRemote()
|
||||||
branch.merge = branch_merge
|
branch.merge = branch_merge
|
||||||
if not branch.merge.startswith("refs/") and not ID_RE.match(
|
if not branch.merge.startswith("refs/") and not IsId(branch_merge):
|
||||||
branch_merge
|
|
||||||
):
|
|
||||||
branch.merge = R_HEADS + branch_merge
|
branch.merge = R_HEADS + branch_merge
|
||||||
|
|
||||||
if revision is None:
|
if revision is None:
|
||||||
@ -2077,7 +2072,7 @@ class Project(object):
|
|||||||
)
|
)
|
||||||
b.Wait()
|
b.Wait()
|
||||||
finally:
|
finally:
|
||||||
if ID_RE.match(old):
|
if IsId(old):
|
||||||
self.bare_git.DetachHead(old)
|
self.bare_git.DetachHead(old)
|
||||||
else:
|
else:
|
||||||
self.bare_git.SetHead(old)
|
self.bare_git.SetHead(old)
|
||||||
@ -2379,7 +2374,6 @@ class Project(object):
|
|||||||
retry_sleep_initial_sec=4.0,
|
retry_sleep_initial_sec=4.0,
|
||||||
retry_exp_factor=2.0,
|
retry_exp_factor=2.0,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
is_sha1 = False
|
|
||||||
tag_name = None
|
tag_name = None
|
||||||
# The depth should not be used when fetching to a mirror because
|
# The depth should not be used when fetching to a mirror because
|
||||||
# it will result in a shallow repository that cannot be cloned or
|
# it will result in a shallow repository that cannot be cloned or
|
||||||
@ -2391,8 +2385,7 @@ class Project(object):
|
|||||||
if depth:
|
if depth:
|
||||||
current_branch_only = True
|
current_branch_only = True
|
||||||
|
|
||||||
if ID_RE.match(self.revisionExpr) is not None:
|
is_sha1 = bool(IsId(self.revisionExpr))
|
||||||
is_sha1 = True
|
|
||||||
|
|
||||||
if current_branch_only:
|
if current_branch_only:
|
||||||
if self.revisionExpr.startswith(R_TAGS):
|
if self.revisionExpr.startswith(R_TAGS):
|
||||||
@ -2419,7 +2412,7 @@ class Project(object):
|
|||||||
# * otherwise, fetch all branches to make sure we end up with
|
# * otherwise, fetch all branches to make sure we end up with
|
||||||
# the specific commit.
|
# the specific commit.
|
||||||
if self.upstream:
|
if self.upstream:
|
||||||
current_branch_only = not ID_RE.match(self.upstream)
|
current_branch_only = not IsId(self.upstream)
|
||||||
else:
|
else:
|
||||||
current_branch_only = False
|
current_branch_only = False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user