p-doom/crowd-code-dataset-0.2 huggingface dataset:
[content] crowd-pilot/crowd-pilot/serialization_utils.py (python)
            case "git_branch_checkout":
                _flush_all_pending_edits()
                _flush_terminal_output_buffer()
                branch_info = row["Text"]
                branch_str = str(branch_info).replace("\
", "
").replace("\
", "
")
                parts.append(f"<act git_branch_checkout />")
                parts.append(f"// git: {_clean_text(branch_str)}")
[content] crowd-pilot/crowd-pilot/serialization_utils.py (python)
            case "git_branch_checkout":
                _flush_all_pending_edits()
                _flush_terminal_output_buffer()
                branch_info = row["Text"]
                branch_str = str(branch_info).replace("\
", "
").replace("\
", "
")
                cleaned = _clean_text(branch_str)
                branch_name = None
                # Try to extract branch name from common messages
                m = re.search(r"[Ss]witched to (?:a new )?branch '([^']+)'", cleaned)
                if not m:
                    m = re.search(r"[Ss]witched to (?:a new )?branch \"([^\"]+)\"", cleaned)
                if not m:
                    m = re.search(r"[Bb]ranch[:\\s]+([A-Za-z0-9._/\\-]+)", cleaned)
                if m:
                    branch_name = m.group(1).strip()
                else:
                    # Fallbacks: single-token line or last quoted segment or last token
                    # Prefer last quoted segment if any
                    q = re.findall(r"'([^']+)'|\"([^\"]+)\"", cleaned)
                    if q:
                        # q is list of tuples; pick the non-empty group from the last match
                        last = q[-1]
                        branch_name = (last[0] or last[1]).strip()
                    else:
                        lines = [ln.strip() for ln in cleaned.splitlines() if ln.strip()]
                        if lines and re.fullmatch(r"[A-Za-z0-9._/\\-]+", lines[-1]):
                            branch_name = lines[-1]
                        else:
                            # As a last resort, take the last token
                            tokens = cleaned.split()
                            if tokens:
                                branch_name = tokens[-1].strip(" '\"")
                # Safe-quote branch if it contains special characters
                branch_for_shell = branch_name or cleaned
                if re.search(r"[^A-Za-z0-9._/\\-]", branch_for_shell):
                    branch_for_shell = "'" + branch_for_shell.replace("'", "'\"'\"'") + "'"
                cmd = f"git checkout {branch_for_shell}"
                parts.append(_fenced_block(file_path, "bash", _clean_text(cmd)))
[content] crowd-pilot/crowd-pilot/serialization_utils.py (python)
            case "git_branch_checkout":
                _flush_all_pending_edits()
                _flush_terminal_output_buffer()
                branch_info = row["Text"]
                branch_str = str(branch_info).replace("\
", "
").replace("\
", "
")
                cleaned = _clean_text(branch_str)
                branch_name = None
                # Try to extract branch name from common messages
                # First try: "Switched from branch 'X' to 'Y'" format
                m = re.search(r"to '([^']+)'", cleaned)
                if not m:
                    m = re.search(r"to \"([^\"]+)\"", cleaned)
                if not m:
                    # Second try: "Switched to (a new) branch 'X'" format
                    m = re.search(r"[Ss]witched to (?:a new )?branch '([^']+)'", cleaned)
                if not m:
                    m = re.search(r"[Ss]witched to (?:a new )?branch \"([^\"]+)\"", cleaned)
                if not m:
                    m = re.search(r"[Bb]ranch[:\\s]+([A-Za-z0-9._/\\-]+)", cleaned)
                if m:
                    branch_name = m.group(1).strip()
                else:
                    # Fallbacks: single-token line or last quoted segment or last token
                    # Prefer last quoted segment if any
                    q = re.findall(r"'([^']+)'|\"([^\"]+)\"", cleaned)
                    if q:
                        # q is list of tuples; pick the non-empty group from the last match
                        last = q[-1]
                        branch_name = (last[0] or last[1]).strip()
                    else:
                        lines = [ln.strip() for ln in cleaned.splitlines() if ln.strip()]
                        if lines and re.fullmatch(r"[A-Za-z0-9._/\\-]+", lines[-1]):
                            branch_name = lines[-1]
                        else:
                            # As a last resort, take the last token
                            tokens = cleaned.split()
                            if tokens:
                                branch_name = tokens[-1].strip(" '\"")
                # Safe-quote branch if it contains special characters
                branch_for_shell = branch_name or cleaned
                if re.search(r"[^A-Za-z0-9._/\\-]", branch_for_shell):
                    branch_for_shell = "'" + branch_for_shell.replace("'", "'\"'\"'") + "'"
                cmd = f"git checkout {branch_for_shell}"
                parts.append(_fenced_block(file_path, "bash", _clean_text(cmd)))
[content] crowd-pilot/crowd-pilot/serialization_utils.py (python)
            case "git_branch_checkout":
                _flush_all_pending_edits()
                _flush_terminal_output_buffer()
                branch_info = row["Text"]
                branch_str = str(branch_info).replace("\
", "
").replace("\
", "
")
                cleaned = _clean_text(branch_str)
                # Extract branch name from "Switched from branch 'X' to 'Y'" format
                m = re.search(r"to '([^']+)'", cleaned)
                if not m:
                    raise ValueError(f"Could not extract branch name from git checkout message: {cleaned}")
                branch_name = m.group(1).strip()
                # Safe-quote branch if it contains special characters
                if re.search(r"[^A-Za-z0-9._/\\-]", branch_name):
                    branch_name = "'" + branch_name.replace("'", "'\"'\"'") + "'"
                cmd = f"git checkout {branch_name}"
                parts.append(_fenced_block(file_path, "bash", _clean_text(cmd)))
[content] crowd-pilot/crowd-pilot/serialization_utils.py (python)
m = re.search(r"[Bb]ranch[:\\s]+([A-Za-z0-9._/\\-]+)", cleaned)
                if m:
                    branch_name = m.group(1).strip()
                else:
                    # Fallbacks: single-token line or last quoted segment or last token
                    # Prefer last quoted segment if any
                    q = re.findall(r"'([^']+)'|\"([^\"]+)\"", cleaned)
                    if q:
                        # q is list of tuples; pick the non-empty group from the last match
                        las