mirror of https://github.com/commaai/openpilot.git
log git commit date (#31490)
* log git commit date * unix ts * fix * bump cereal * cleanup
This commit is contained in:
parent
5a441ec0c4
commit
0723c2bc5f
2
cereal
2
cereal
|
@ -1 +1 @@
|
|||
Subproject commit bd31b25aacc5b39f36cedcb0dabd05db471da59f
|
||||
Subproject commit 7de3c7111e78d87f9c43e2861a3e18aa59fde956
|
|
@ -125,6 +125,7 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||
{"ForcePowerDown", PERSISTENT},
|
||||
{"GitBranch", PERSISTENT},
|
||||
{"GitCommit", PERSISTENT},
|
||||
{"GitCommitDate", PERSISTENT},
|
||||
{"GitDiff", PERSISTENT},
|
||||
{"GithubSshKeys", PERSISTENT},
|
||||
{"GithubUsername", PERSISTENT},
|
||||
|
|
|
@ -19,7 +19,7 @@ from openpilot.selfdrive.athena.registration import register, UNREGISTERED_DONGL
|
|||
from openpilot.common.swaglog import cloudlog, add_file_handler
|
||||
from openpilot.system.version import is_dirty, get_commit, get_version, get_origin, get_short_branch, \
|
||||
get_normalized_origin, terms_version, training_version, \
|
||||
is_tested_branch, is_release_branch
|
||||
is_tested_branch, is_release_branch, get_commit_date
|
||||
|
||||
|
||||
|
||||
|
@ -66,6 +66,7 @@ def manager_init() -> None:
|
|||
params.put("TermsVersion", terms_version)
|
||||
params.put("TrainingVersion", training_version)
|
||||
params.put("GitCommit", get_commit())
|
||||
params.put("GitCommitDate", get_commit_date())
|
||||
params.put("GitBranch", get_short_branch())
|
||||
params.put("GitRemote", get_origin())
|
||||
params.put_bool("IsTestedBranch", is_tested_branch())
|
||||
|
|
|
@ -44,6 +44,7 @@ kj::Array<capnp::word> logger_build_init_data() {
|
|||
std::map<std::string, std::string> params_map = params.readAll();
|
||||
|
||||
init.setGitCommit(params_map["GitCommit"]);
|
||||
init.setGitCommitDate(params_map["GitCommitDate"]);
|
||||
init.setGitBranch(params_map["GitBranch"]);
|
||||
init.setGitRemote(params_map["GitRemote"]);
|
||||
init.setPassive(false);
|
||||
|
|
|
@ -107,6 +107,7 @@ class TestLoggerd:
|
|||
# param, initData field, value
|
||||
("DongleId", "dongleId", dongle),
|
||||
("GitCommit", "gitCommit", "commit"),
|
||||
("GitCommitDate", "gitCommitDate", "date"),
|
||||
("GitBranch", "gitBranch", "branch"),
|
||||
("GitRemote", "gitRemote", "remote"),
|
||||
]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import subprocess
|
||||
from typing import List, Optional, Callable, TypeVar
|
||||
from typing import List, Callable, TypeVar
|
||||
from functools import lru_cache
|
||||
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
|
@ -22,7 +22,7 @@ def run_cmd(cmd: List[str]) -> str:
|
|||
return subprocess.check_output(cmd, encoding='utf8').strip()
|
||||
|
||||
|
||||
def run_cmd_default(cmd: List[str], default: Optional[str] = None) -> Optional[str]:
|
||||
def run_cmd_default(cmd: List[str], default: str = "") -> str:
|
||||
try:
|
||||
return run_cmd(cmd)
|
||||
except subprocess.CalledProcessError:
|
||||
|
@ -31,17 +31,22 @@ def run_cmd_default(cmd: List[str], default: Optional[str] = None) -> Optional[s
|
|||
|
||||
@cache
|
||||
def get_commit(branch: str = "HEAD") -> str:
|
||||
return run_cmd_default(["git", "rev-parse", branch]) or ""
|
||||
return run_cmd_default(["git", "rev-parse", branch])
|
||||
|
||||
|
||||
@cache
|
||||
def get_commit_date(commit: str = "HEAD") -> str:
|
||||
return run_cmd_default(["git", "show", "--no-patch", "--format='%ct %ci'", commit])
|
||||
|
||||
|
||||
@cache
|
||||
def get_short_branch() -> str:
|
||||
return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "HEAD"]) or ""
|
||||
return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
||||
|
||||
|
||||
@cache
|
||||
def get_branch() -> str:
|
||||
return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]) or ""
|
||||
return run_cmd_default(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"])
|
||||
|
||||
|
||||
@cache
|
||||
|
@ -51,7 +56,7 @@ def get_origin() -> str:
|
|||
tracking_remote = run_cmd(["git", "config", "branch." + local_branch + ".remote"])
|
||||
return run_cmd(["git", "config", "remote." + tracking_remote + ".url"])
|
||||
except subprocess.CalledProcessError: # Not on a branch, fallback
|
||||
return run_cmd_default(["git", "config", "--get", "remote.origin.url"]) or ""
|
||||
return run_cmd_default(["git", "config", "--get", "remote.origin.url"])
|
||||
|
||||
|
||||
@cache
|
||||
|
@ -132,3 +137,4 @@ if __name__ == "__main__":
|
|||
print(f"Branch: {get_branch()}")
|
||||
print(f"Short branch: {get_short_branch()}")
|
||||
print(f"Prebuilt: {is_prebuilt()}")
|
||||
print(f"Commit date: {get_commit_date()}")
|
||||
|
|
Loading…
Reference in New Issue