# # Copyright (C) 2023 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """APIs for interacting with git repositories.""" # TODO: This should be partially merged with the git_utils APIs. # The bulk of this should be lifted out of the tests and used by the rest of # external_updater, but we'll want to keep a few of the APIs just in the tests because # they're not particularly sensible elsewhere (specifically the shorthand for commit # with the update_files and delete_files arguments). It's probably easiest to do that by # reworking the git_utils APIs into a class like this and then deriving this one from # that. from __future__ import annotations
import subprocess from pathlib import Path
class GitRepo: """A git repository for use in tests."""
def lightweight_tag(self, name: str, ref: str | None = None) -> None: """Creates a lightweight tag at the given ref, or HEAD if not provided."""
args = ["tag", name] if ref isnotNone:
args.append(ref)
self.run(args)
def commit_message_at_revision(self, revision: str) -> str: """Returns the commit message of the given revision.""" # %B is the raw commit body # %- eats the separator newline # Note that commit messages created with `git commit` will always end with a # trailing newline. return self.run(["log", "--format=%B%-", "-n1", revision])
def file_contents_at_revision(self, revision: str, path: str) -> str: """Returns the commit message of the given revision.""" # %B is the raw commit body # %- eats the separator newline return self.run(["show", "--format=%B%-", f"{revision}:{path}"])
def describe(self, sha: str) -> str: """Returns the nearest tag to a given commit."""
cmd = ["describe", "--contains", sha] return self.run(cmd).strip()
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.