Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions cadetrdm/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -1768,20 +1768,29 @@ def _add_branch_name_to_log(self) -> None:
"""
Update the TSV file by adding a 'project_repo_branch' column.

The branch name is extracted from the 'output_repo_commit_message' field.
The branch name is extracted from the 'Output repo branch' field.
"""
self.checkout(self.main_branch)

with open(self.output_log_file_path, "r") as f:
reader = csv.DictReader(f, delimiter="\t")
rows = list(reader)

if not rows:
return

fieldnames = list(rows[0].keys())

# support old/new header names
if "output_repo_branch" in rows[0]:
branch_col = "output_repo_branch"
elif "Output repo branch" in rows[0]:
branch_col = "Output repo branch"

# Add new column to header if not present
if "project_repo_branch" not in rows[0]:
for row in rows:
commit_msg = row["output_repo_branch"]
branch = commit_msg.split("_")[2]
branch = branch_colc.split("_")[2]
row["project_repo_branch"] = branch

if "project_repo_branch" not in fieldnames:
Expand Down