0

With the help of this answer and this post I already got a basic idea how to share hooks with the full team. The remaining "problem" with those two approaches is that everyone needs to run git config core.hooksPath <path hooks under version control>. It is of course easy to forget this (especially when making a fresh clone) so I'm searching for something that will automatically do this. I have read some things about package.json (here or in the comment section of this). But I have no clue where this package.json comes from/where to find it. My initial feeling is that it has something to do with javascript code, but my repository is c++.

Could someone in more detail explain where to find this package.json (if also applicable for c++) or maybe tell about new features of git/ new ways to get the automatic behaviour?

(More detail about the use case: I want to add a (small) sqllite database to the repository and I have read that it's kind of bad to commit binary files to git. So I learned one way (comments) is to do a pre commit(?) hook that dumps the file into sql and then a post-checkout(?) hook that converts the sql back to binary sqllite database)

C. Binair
  • 419
  • 4
  • 14
  • package.json is something else, that's from the node package manager. You might use NuGet packages if its a C++ project..? You only have to configure the `hooksPath` once after you have cloned. You can expect that from a developer I think. Git didn't think that far to force githooks on you, but that's just a one-time setup per project. – Peter Krebs Aug 27 '21 at 13:31
  • 2
    git *intentionally* doesn't force hooks on you because it would be *terrible* security problem if it did. – larsks Aug 27 '21 at 14:16
  • Do you need this action to be run on *every* commit created by anyone ? or would having two scripts (say `dump'sh` and `reload.sh`) called explicitly by the developer be ok ? – LeGEC Aug 27 '21 at 16:39
  • out of curiosity : what kind of data is stored in that sqlite database ? – LeGEC Aug 27 '21 at 17:07
  • @LeGEC two scripts would work as well, but then again it's not automatic. I prefer to make it automatic such that people can't make mistakes. For your second question it's a property database. It stores constant density, viscosity, etc. Or density, viscosity, etc correlations. – C. Binair Sep 13 '21 at 09:38
  • 1
    ok. Is there a technical reason why this set of data should be stored as a sqlite databse ? or can you store these constants in a more text oriented format (e.g : a sql script, a json file, a basic `name: value` file ...), and teach your code to read *that* format -- even load it in a sqlite database if relevant ? – LeGEC Sep 13 '21 at 11:38
  • The point that itches in my mind is : you have some data, which influences the behavior of your code, but there's a specific part of dealing with that data which wouldn't depend on your code at all, but rather on something (hooks, scripts ...) behaving correctly when running git commands. – LeGEC Sep 13 '21 at 11:42
  • @LeGEC I could "teach my code to read another format", but I wanted to use sqlite because that would be more user friendly. But otherwise yes your comment is certainly valid. I'm actually working with just the dumped sql now and just convert that to db in my code. – C. Binair Sep 13 '21 at 12:08

0 Answers0