gcbenison
gcbenison

Reputation: 11963

Assert that submodule always pointed to a valid commit

A common mistake with submodules is to commit in the superproject a subproject hash pointing at a commit that isn't reachable by everybody using the superproject (for instance, the commit may only exist on someone's personal machine.)

I would like to audit an entire history to make sure that every subproject commit ever referenced by the superproject actually exists in a given remote repository. Is there a good way to do that?

Upvotes: 1

Views: 81

Answers (1)

VonC
VonC

Reputation: 1324218

You could try this GitHub project git-pre-push-submodule-check (from Konrad Malawski aka ktoso) which does the check (ruby script):

From now on, you may want to use pom instead of other push methods, here's how it would look like:

When you have unpushed changes in submodules:

$ git pom
Checking [styles-common] submodule for unpushed commits...
**********************************************************
  You have 2 unpushed commits within styles-common:
  1a87491 added more fluffy icons
  bd40c09 flash now has nice round corners
**********************************************************
Aborting push.

When you don't have unpushed changes in submodules:

$ ./check_submodule_pushed.rb
Checking [styles-common] submodule for unpushed commits...
Seems all submodule commits you refer to are reachable, let's push!

But my point is: I don't know of a native way of checking if a submodule has been push before pushing its parent repo.

Upvotes: 1

Related Questions