Page MenuHomeSoftware Heritage

scanner: strip the path passed as argument from output
Closed, MigratedEdits Locked

Description

in the following example:

$ swh scanner scan -f json -x '*.git' ~/swh/git/helloworld
{
    "/home/zack/swh/git/helloworld/COPYING": {
        "known": true,
        "swhid": "swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2"
    },
    "/home/zack/swh/git/helloworld/Makefile": {
        "known": true,
        "swhid": "swh:1:cnt:a8becc46666b57d34e703a90660029507dac87a2"
    },
    "/home/zack/swh/git/helloworld/README.md": {
        "known": true,
        "swhid": "swh:1:cnt:4ec6b1e9b2e32f52c13c3b4d1faa688829d2d363"
    },
    "/home/zack/swh/git/helloworld/src": {
        "known": true,
        "swhid": "swh:1:dir:b94a90cd37b572636244856a02214da21504e754"
    }
}

it is pointless to emit the common /home/zack/swh/git/helloworld path prefix in all entries. Because (1) it increases output size for no good reason, (2) it makes the invocation not invariant, i.e., the output will be different when invoked as ~/swh/git/helloworld vs when invoked as . from within the root dir.

We should make all paths in output relative to the root scanning dir.

cc: @DanSeraf

Revisions and Commits