Fix a confusing crash creating a DiffCommit with no committer date.
Review Request #11317 — Created Dec. 7, 2020 and submitted
When creating a
DiffCommitwithcommitter_date=None, which could
happen for some commits, we'd see a confusing error:TypeError: 'committer_date' is an invalid keyword argument for this functionThis was a bit confusing because, although
committer_dateis a
property and not a model field, it clearly works in most situations
(we've been creating multi-commit review requests for some time now).The failure only manifests when passing
Noneas the value, which led
to a crash in the property when trying to call a method on it. This
raised anAttributeError, which triggered a handler in Django's
BaseModelclass, making it think thatcommitter_datedidn't exist.This change fixes the property to work with
Nonevalues. It also
applies the same logic toauthor_date, so that if aNoneis passed
in, we'll just setNonein the fields, allowing Django's own
validation to occur.Unit tests were added for both of these properties.
Unit tests pass.
Hit this in production use and verified the fix.
| Summary | ID | 
|---|---|
| 083e4ac1577706d2052fdcdbaf461917a374adda | 
| Description | From | Last Updated | 
|---|---|---|
| 
       
        F841 local variable 'commit' is assigned to but never used  | 
      
        |