matomo icon indicating copy to clipboard operation
matomo copied to clipboard

Dev: use git hook to update submodules on changes

Open rr-it opened this issue 1 year ago • 2 comments

Summary

Submodules are not updated by default on git-checkout or git-merge.

So every now and then you must manually update the submodules:

See: https://developer.matomo.org/guides/git#cloning-a-repository

git submodule update --init 

May we run git submodule update automatically by git hook?

  • For performance reasons only run it when it is neccessary e.g. the file .gitmodules has changed.
  • Use yorkie to hook into the git hooks. It is not a direct dependency right now, but already included because of sub-dependencies. See cat .git/hooks/post-checkout:
    #!/bin/sh
    #yorkie 2.0.0
    […]
    
  • Use simple bash script to make it run on Linux, macOS and Windows. (git on windows supports some kind of unix bash: MINGW64 / git-bash.exe)

How does the use of git hooks influence the continuous integration, testing and packaging workflow?


There is a new git config option submodule.recurse:

See: https://git-scm.com/book/en/v2/Git-Tools-Submodules#_cloning_submodules Moreover, if you want to make Git always pull with --recurse-submodules, you can set the configuration option submodule.recurse to true (this works for git pull since Git 2.15). This option will make Git use the --recurse-submodules flag for all commands that support it (except clone).

However:

See: https://stackoverflow.com/questions/1899792/why-is-git-submodule-not-updated-automatically-on-git-checkout/43854593#43854593 submodule.recurse makes git fetch fetch all submodules every time This makes the option basically unusably slow, because the fetch happens even when the submodules are up to date, as it tries to fetch an branch updates from those submodules.


Your Environment

  • Matomo Version:
  • PHP Version:
  • Server Operating System:
  • Additionally installed plugins:

rr-it avatar Feb 05 '24 11:02 rr-it

FYI this is documented in https://developer.matomo.org/guides/contributing-to-piwik-core#switching-between-branches but seems it's not there yet for submodules

tsteur avatar Feb 06 '24 21:02 tsteur

As mentioned on the PR. Instead of adding such a hook to our codebase, we should update the documentation mentioned before and add it there.

sgiehl avatar Feb 12 '24 12:02 sgiehl