Is there any automatic way to update the parent git repo to point to the latest commit of its submodule?
Asked Answered
S

2

4

Every time I push a commit to the submodule I need to update the parent repo to the latest commit in the submodule. Is there any automatic way to do that in the remote?

Every time push a commit in the submodule repo i want the parent to automatically point to the latest commit of the child repo. Please suggest if its possible and how?

Stapes answered 5/6, 2019 at 2:31 Comment(0)
A
0

If you have control over your GitLab server, you might consider a post-receive hook (a custom hook) associated to your remote submodule repository, which would:

  • go to a checked-out parent repository
  • execute git submodule update --remote: that would update all submodules to their latest master (by default) commit.
  • add, commit, and push

But if it is gitlab.com, the process becomes more convoluted and will involve a webhook.
That means you will have to implement/install a listener which will do the same operations whenever a push event to your remote submodule repository is triggered.

Atheling answered 5/6, 2019 at 5:17 Comment(0)
G
5

Using gitlab-ci in the submodule, I was able to trigger the parent to automatically update the master branch in parent when a merge request for the submodule master branch is completed.

stages:
  - build

build_job_dev:
  stage: build
  variables:
    PLUGIN_NAME: coppercrm  
  trigger:
    project: Plugins/parent
    branch: development
  only: 
    - master

I hope this could help someone who is looking for updating parent repo whenever a submodule updates

Glia answered 21/8, 2021 at 7:11 Comment(1)
If I understand that correctly, this only triggers the parents repo pipeline. How do you update (and maybe also commit) the submodules in the parent?Herb
A
0

If you have control over your GitLab server, you might consider a post-receive hook (a custom hook) associated to your remote submodule repository, which would:

  • go to a checked-out parent repository
  • execute git submodule update --remote: that would update all submodules to their latest master (by default) commit.
  • add, commit, and push

But if it is gitlab.com, the process becomes more convoluted and will involve a webhook.
That means you will have to implement/install a listener which will do the same operations whenever a push event to your remote submodule repository is triggered.

Atheling answered 5/6, 2019 at 5:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.