buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

FR: default-RO version control enhancements

Open beasleyr-vmw opened this issue 5 years ago • 0 comments

Dormant files in a Perforce VCS workspace are read-only by default. Users must issue a p4 edit <file> before editing a file. Consequently, one cannot readily use buildozer or buildifier in a Perforce workspace without issuing a p4 edit $(find . -name BUILD -or -name \*.bzl -or -name WORKSPACE) first. This is problematic for a variety of reasons.

Some ideas

-dryrun or -nameonly etc options

It would be useful if the tools had an option to only print the names of files which would be edited. Users could then issue commands like buildozer -dryrun 'replace * foo bar' //...:* | xargs p4 edit to edit only the relevant set of files.

buildifier has -lint=warn -mode=check, but its output is inconsistent and tricky to parse. buildozer has no comparable option.

VCS hooks

GNU patch will prompt users and run p4 edit on their behalf when editing files in a Perforce workspace. Scanning its ChangeLog, it also advertises (presumably equivalent) ClearCase and RCS support. I'm not sure that anyone wants to bake in VCS-specific logic, but maybe the tools could take an -edithook option for a shell snippet which the buildtools would execute before trying to write to a file.

$ buildozer -edithook 'p4 edit' 'replace * foo bar //...:*'

beasleyr-vmw avatar Oct 23 '19 12:10 beasleyr-vmw