Hacker News new | past | comments | ask | show | jobs | submit login
How to pretend that some lines aren't versioned in Git (sa-web.fr)
1 point by ssimono on Dec 5, 2022 | hide | past | favorite | 2 comments



Date is a very bad piece of data to store in a auto-generated file. 1. It will get updated regardless of actual changes to the file, which means you will get a git commit each time you run the regeneration. 2. It's superfluous. The date of the last update is contained in the git history - ie. `git log file.ext` will give you exactly the last time it was regenerated 3. If you include the file in any kind of build, changing the date will invalidate the build caches and force a recompile. Potentially a very expensive recompile if it's at a top of a dependency tree. 4. It depends on the system. Running the autogenerate tool on different machines will return different outputs, so for example you might have issues checking in CI that it was generated correctly.

A simple solution to your problem is to use something stable - a content hash. Ideally you will want something reasonably fast, but also cryptographically secure in case you want to extend its use later - but in general any decent hash will do.


This is a hack I put together to simulate a feature where you could exclude some lines from being tracked with git, based on some patterns




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: