statsd: fix crash if there is no git repository (#23775)

* fix crash if there is no git repository

* return default

Co-authored-by: Willem Melching <willem.melching@gmail.com>
pull/23752/head
Jack Huang 3 years ago committed by GitHub
parent 95da470795
commit a84ddaecf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      selfdrive/version.py

@ -55,11 +55,15 @@ def get_origin(default: Optional[str] = None) -> Optional[str]:
@cache @cache
def get_normalized_origin(default: Optional[str] = None) -> Optional[str]: def get_normalized_origin(default: Optional[str] = None) -> Optional[str]:
return get_origin()\ origin = get_origin()
.replace("git@", "", 1)\
.replace(".git", "", 1)\ if origin is None:
.replace("https://", "", 1)\ return default
.replace(":", "/", 1)
return origin.replace("git@", "", 1) \
.replace(".git", "", 1) \
.replace("https://", "", 1) \
.replace(":", "/", 1)
@cache @cache

Loading…
Cancel
Save