Skip to content

index.add with path_rewriter conflicts with directory paths expansion #1242

Open
@zhiltsov-max

Description

@zhiltsov-max

It seems that if index.add() is called with path_rewriter, it would cancel out the logic for automatic directory paths expansion and traversal. My use case is to call add with a directory and replace (truncate the dir prefix) the paths of the upcoming commit.

/repo/a/b/c/<files and dirs>  <-- I want these files in a commit with a/b/c/ removed

Current behaviour:
Paths replaced first and then directories are not expanded.

Current workaround:
Expand directory paths manually with os.walk, glob etc.

Expected behavior:

repo.index.add('a/b/c/', path_rewriter=lambda p: osp.relpath(p, 'a/b/c/'))
# index includes <files> with a/b/c/ prefix removed in paths

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions