DEV Community

ginwakeup
ginwakeup

Posted on

1

Submoduler: A tool to automatically keep git submodules updated through Python & Docker

Intro

Most of the comments I read online about git submodules go from:
"avoid them"
"never use submodules"
"use one big repo"

And after working with them for a year now I can understand why.

I would myself suggest to stay away from submodules, as they are not exactly immediate to understand and not a nice thing to maintain either.

That said, submodules can be useful at times.

For example:

  • You could have multiple repositories to which you want to provide the same developer scripts. One way of achieving this could be to have them live in a separate repository and add this as a submodule.
  • You have a very tight relationship between two repos, but at the same time you do not want (or can't) use a monorepo.

Submodules in a Nutshell

If you do not know what submodules are, they are simply links to a specific commit in another repository.

That's where the trick is.

Read again:
They are not links to another repository, they are links to a specific commit in another repository.

Let's imagine the current scenario:

  • We have repository_a and repository_b
  • We create a submodule of repository_b inside repository_a
  • All works good, we can see repository_a in Git and it gets pulled together with repository_b.

At some point, we might make a change inside repository_b.
We then fetch/pull inside repository_a, and surprise: the change is not there.

That's because, again, submodules point to a specific commit.

The process to update a submodule is quite straight forward:

cd repository_a
git submodule update --remote --recursive
Enter fullscreen mode Exit fullscreen mode

Great! The submodule is now updated and we see the latest changes we pushed to repository_b.

What about doing this every day, every time there's a change in repository_b?
What if repository_b is a submodule in 10/20/30 repositories?

Too much work.

Submoduler

That's where Submoduler comes in.

Submoduler is a simple Python app that can run in a Docker Container, and loops a list of repositories provided by the user to update all of their submodules in an automatic fashion.

You can find it here:
https://github.com/ginwakeup/submoduler

You can using by quickly pulling the Docker Image and running it with a simple configuration.yaml in which you can list the repositories to be updated as https urls together with options, and then run it passing a user and pat through the -env flag.

Hopefully this will be of some help to someone!

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay