Skip to content

Commit a84ddae

Browse files
jackhong12pd0wm
andauthored
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 <[email protected]>
1 parent 95da470 commit a84ddae

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

selfdrive/version.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ def get_origin(default: Optional[str] = None) -> Optional[str]:
5555

5656
@cache
5757
def get_normalized_origin(default: Optional[str] = None) -> Optional[str]:
58-
return get_origin()\
59-
.replace("git@", "", 1)\
60-
.replace(".git", "", 1)\
61-
.replace("https://", "", 1)\
62-
.replace(":", "/", 1)
58+
origin = get_origin()
59+
60+
if origin is None:
61+
return default
62+
63+
return origin.replace("git@", "", 1) \
64+
.replace(".git", "", 1) \
65+
.replace("https://", "", 1) \
66+
.replace(":", "/", 1)
6367

6468

6569
@cache

0 commit comments

Comments
 (0)