softprops / afterparty

rust github webhook server
MIT License
55 stars 13 forks source link

Fix push event & deal with clashing struct definitions for identical names #15

Closed ms705 closed 7 years ago

ms705 commented 7 years ago

@softprops @clux

This is an extended version of #13, which fixes the concern related to the repeated definition of the "Author" struct as different JSON objects. The strategy I applied here is the same as is used for recursive definitions already: when a struct with the same name as an existing definition is encountered, the name is disambiguated by adding the container name as a prefix.

This works well for me and allows all events to exist in events.txt without breaking Push and Ping. However:

  1. It is overeager, because repeated structs are redefined under different names even if their definition is identical (i.e., we may end up with several copies of what is really the same struct).
  2. It may break existing code, since the names of some nested structs have changed.

If neither of those is a concern, this fix should comprehensively address #13.

ms705 commented 7 years ago

Fixed the first drawback -- the code now checks for definition equality before generating a new struct. This has somewhat reduced the number of extra structs.

softprops commented 7 years ago

@ms705 thanks. I'll dig into this and get back to you soon.