mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-09-26 00:30:32 +00:00
project: centralize safe branch and commit resolution
Resolve commit-ish values through one typed helper using rev-parse --verify --quiet and, on Git 2.30+, --end-of-options. Reject option-like revisions on older clients, reuse the helper for project and manifest resolution, and validate user branch names with check-ref-format --branch. Bug: 553599402 Change-Id: I2dda49ff3e781cec14d3b84263a8dace06b4073f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/623182 Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Brian Gan <brgan@google.com>
This commit is contained in:
committed by
gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
6541729a18
commit
d27034bf62
@@ -70,6 +70,19 @@ class _GitCall:
|
||||
git = _GitCall()
|
||||
|
||||
|
||||
def IsValidBranchName(name: str) -> bool:
|
||||
"""Return whether |name| is valid where Git expects a branch name."""
|
||||
p = GitCommand(
|
||||
None,
|
||||
["check-ref-format", "--branch", name],
|
||||
capture_stdout=True,
|
||||
capture_stderr=True,
|
||||
add_event_log=False,
|
||||
log_as_error=False,
|
||||
)
|
||||
return p.Wait() == 0
|
||||
|
||||
|
||||
def RepoSourceVersion():
|
||||
"""Return the version of the repo.git tree."""
|
||||
ver = getattr(RepoSourceVersion, "version", None)
|
||||
|
||||
Reference in New Issue
Block a user