Investigate sub-repo permissions simplification / optimisation
Created by: ryanslade
It would appear that Perforce permissions only support basic globbing as mentioned here. Specifically the ... syntax which is the equivilent to ** in most glob packages.
Due to the above, we decided to use the glob package which allows some fairly advanced globbing. We store raw glob patterns based on this library in the database.
Importantly, git also supports globbing for a number of features for example archiving and ls-files and it would be great if we could use this. We can't currently without writing a translation between our stored glob pattern and the git patterns.
Instead of doing this we should use a simpler glob syntax as our source of truth, one that is compatible with git. According to the git documentation this would be anything support libc fnmatch.
This would help for a few reasons:
- Allow us to send filters to git rather than filtering everything after the fact in code
- A simpler syntax is easier to understand and reduces scope. This is especially important once customers start sending us raw patterns via explicit permission syncing.
We may be able to use the fnmatch library. We should check that it's syntax is equivilent to git globs.
Migration
Luckily, we have a version column on our sub_repo_permissions table which would make this switch easier.
- Add code to permission syncing that stores both the new and old syntax with different version numbers (Old=1, New=2)
- In the next release, switch the read code to only read the new syntax with version 2
- At this point we should be free to start adding optimisation that pass these rules through to git. Note that we an only pass include rules, we'll still need to filter exclude rules in code.