psyinfra / onyo

text-based inventory system on top of git
ISC License
3 stars 5 forks source link

Fixing asset comparison to account for comments #637

Closed bpoldrack closed 3 months ago

bpoldrack commented 3 months ago

modify_asset raises a NoopError when there's nothing to do. However, this was based on a dict comparison, leading to the assessment that there isn't anything to do, if comments were the only thing modified. This commit adds a comparison helper, that accounts for ruamel's comment annotation. Builtin by ruamel operator overwrites (__eq__, __neq__, __contains__) don't work for us, b/c a CommentToken's start- and end markers may end up being FileMark objects. And these contain the path to a file this was read from. Hence, comparing across files doesn't work as we need it to, b/c assets are edited in a temp location, so that the edited asset object is connected to a different file path. This led to edits that change nothing but comments being ignored by onyo edit and therefore nothing was committed.

Closes #586

Second commit is a miniscule fix of a test I stumbled upon. Not actually related to the topic above.