[PATCH] models: Validate Project.linkname does not contain forward slash

Thomas Bracht Laumann Jespersen t at laumann.xyz
Tue Sep 8 23:58:31 AEST 2020


> > I hard a hard time satisfying flake8, so I ended up disabling the pre-commit
> > hook. I also looked over the documentation for contributors and figure that if
> > a release note is required, just let me know then I'll add it.
> 
> TIL we have precommit hooks. I've been contributing to patchwork for a few
> years now...
> 
> In any case, it also causes the test suite to fail its flake8 check. Perhaps
> we need to exclude the migrations directory?

I can also just bite the bullet and get precommit working, but it does seem
aggressive to fail tests on auto-generated files.

> > diff --git a/patchwork/models.py b/patchwork/models.py
> > index 77ab924..9027219 100644
> > --- a/patchwork/models.py
> > +++ b/patchwork/models.py
> > @@ -31,6 +31,13 @@ def validate_regex_compiles(regex_string):
> >           raise ValidationError('Invalid regular expression entered!')
> > +def validate_project_linkname(linkname):
> > +    if re.fullmatch(r'[^/]+', linkname) is None:
> 
> This could just be "if '/' in linkname:"

Sure, that's way simpler, I'll submit another patch. Thanks for the feedback!

-- Thomas


More information about the Patchwork mailing list