Skip to content

Crashes on python file with "Hunk lines should be present in matched lines"Β #995

Description

@juliancoffee

(1) A description of the issue. A screenshot is often helpful too.

% make diff
difft old.py new.py

thread 'main' (17348282) panicked at /Users/illiadenysenko/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/difftastic-0.68.0/src/display/hunks.rs:667:31:
Hunk lines should be present in matched lines
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
make: *** [diff] Error 101

(2) A copy of what you're diffing. If you're diffing files, include the before and after files. If you're using difftastic with a VCS repository (e.g. git), include the URL and commit hash.
new.py

from pathlib import Path

from fastapi import FastAPI


def create_app_from_runtime_config() -> FastAPI:
    config = load_runtime_config()
    store = RepoMarkStore.open(Path(config.db_path))

    marks = store.list()
    if len(marks) == 0:
        raise SystemExit(
            "No marked repos. Run: dirdiff mark /path/to/repo "
            "--db-path /path/to/db.sqlite"
        )
    return create_app(store, presets_root=config.presets_root)


def handle_mark_command(args: argparse.Namespace) -> None:
    store = RepoMarkStore.open(Path(args.db_path))
    repo_path = Path(args.repo_path)
    if args.name is None:
        resolved_path = repo_path.expanduser().resolve()
        display_name = resolved_path.name
        if not display_name:
            raise SystemExit(
                f"Cannot derive a repo name from path: {resolved_path}"
            )
    else:
        display_name = args.name
    try:
        mark = store.mark(RepoMarkInput(path=repo_path, name=display_name))
    except RepoRegistryError as exc:
        raise SystemExit(str(exc)) from exc
    print(f"Marked repo {mark.id}: {mark.path}", file=sys.stderr)

And old.py

from pathlib import Path
from typing import Any


def create_app_from_runtime_config() -> Any:
    config = load_runtime_config()
    repo_root = (
        Path(config.repo_root).expanduser() if config.repo_root else None
    )
    repo = GitBackend.discover(repo_root=repo_root)
    presets_root = (
        Path(config.presets_root).expanduser() if config.presets_root else None
    )
    preset_repo = PresetBackend.discover(presets_root=presets_root)
    service = TextDiffService(repo)
    git_service = GitDiffService(repo)
    difftastic_service = DifftasticDiffService(repo)
    preset_service = TextDiffService(preset_repo)
    preset_git_service = GitDiffService(preset_repo)
    preset_difftastic_service = DifftasticDiffService(preset_repo)
    defaults = build_defaults(
        service,
        left=config.left,
        right=config.right,
        base_branch=config.base_branch,
        review_branch=config.review_branch,
    )
    return create_app(
        service,
        defaults,
        services={"git": git_service, "difftastic": difftastic_service},
        preset_services={
            "dirdiff": preset_service,
            "git": preset_git_service,
            "difftastic": preset_difftastic_service,
        },
    )

(3) The version of difftastic you're using (see difft --version) and your operating system.

% difft --version
Difftastic 0.68.0

Toolchain: 1.91.0
System:    macos aarch64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions