Skip to content

Commit 85091e3

Browse files
authored
Merge pull request #414 from DSD-DBS/fix/backup-support-capella-6
fix(backup): Handle dates of older Capella versions in commit history
2 parents 23193f9 + 193259b commit 85091e3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

t4c/t4c_cli/backup.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ class CommitHistoryEntry(t.TypedDict):
222222
user: str
223223

224224

225+
def parse_datetime_from_commit_history(date: str) -> datetime.datetime:
226+
if util_capella.is_capella_7_x_x():
227+
return datetime.datetime.fromisoformat(date)
228+
229+
# Older versions of Capella use a format like "01/01/2020, 12:00"
230+
return datetime.datetime.strptime(date, "%d/%m/%Y, %H:%M").replace(
231+
tzinfo=datetime.UTC
232+
)
233+
234+
225235
def get_activities_from_history() -> list[CommitHistoryEntry]:
226236
commit_history = next(
227237
pathlib.Path(config.config.t4c.project_dir_path).glob(
@@ -235,7 +245,7 @@ def get_activities_from_history() -> list[CommitHistoryEntry]:
235245
return [
236246
{
237247
"description": activity.get("description") or "No commit message",
238-
"date": datetime.datetime.fromisoformat(activity["date"]),
248+
"date": parse_datetime_from_commit_history(activity["date"]),
239249
"user": activity.get("user") or "Unknown",
240250
}
241251
for activity in commit_history_json["activityMetadataExport"][

0 commit comments

Comments
 (0)