https://pantsbuild.org/ logo
f

flat-zoo-31952

09/03/2022, 11:14 AM
Is there a simple command to check if each file has only one owner?
h

hundreds-father-404

09/03/2022, 5:53 PM
You can do
./pants list path/to/file.py
and make sure
wc -l
is 1. That is slow if you need to check every file because invoking Pants N times is slow So, you could then use
peek
and inspect the JSON I guess, but that's complicated If you want to do this check in CI, the simplest thing may be to develop a new goal
check-single-owners
. Request
AllTargets
and probably get
SourcesPaths
for each target -- make sure they is no overlpa
👍🏻 1
f

flat-zoo-31952

09/04/2022, 12:42 PM
thanks ... something like
Copy code
sources_paths = await MultiGet(
        Get(SourcesPaths, SourcesPathsRequest(tgt.get(SourcesField))) for tgt in targets
    )

    counter = Counter(file for sp in sources_paths for file in sp.files)
seems to do the trick, although it might be useful to find owners too to help with output, i'll iterate on this
👍 1
2 Views