twosigma / git-meta

Repository for the git-meta project -- build your own monorepo using Git submodules
http://twosigma.github.io/git-meta
BSD 3-Clause "New" or "Revised" License
218 stars 50 forks source link

git meta push pushes current not committed submodules #319

Open novalis opened 7 years ago

novalis commented 7 years ago

If I make a commit in submodule A, and then make a meta commit, and then make another commit in submodule A, git meta push will push the second submodule A commit -- not the one that is in the meta commit being pushed.

abliss commented 7 years ago

And if you close the submodule, it doesn't push at all.

bpeabody commented 7 years ago

The way it works right now is... expedient. I'm not sure that it's tractable to figure out what the exact right set of submodule commits to push is. To do so, you'd first need to determine what meta-repo commits haven't been pushed -- which is always going to be a guess, and which could range between mildly and extremely expensive (e.g., of the user has removed all remote branches you might deduce that all of history is being pushed).

I think a better algorithm than what I currently have (that would address @novalis 's issue) would be to push, for each open submodule, the commit referenced at the tip of the meta-repo commit being pushed. Final validation will have to happen on the back-end as we really have no idea of what's there, unless we want to teach git-meta how to participate in the negotiation process.

abliss commented 6 years ago

Under the assumption that you only push one commit at a time, it would seem simple to examine the tip of the outgoing branch, and push to a synthetic meta ref every submodule changed in that commit.

bpeabody commented 6 years ago

Why would we assume that users push only one commit at a time?

abliss commented 6 years ago

I know it's not philosophically pure, but neither is the currently-implemented solution, and approximately 100% of real-world usage of git meta to date has been one commit at a time. :)

bpeabody commented 6 years ago

I think it's OK to use that point as an optimization, but I don't think the tool should be broken if someone has more than one commit.

abliss commented 6 years ago

Agreed. But the tool is currently broken if you (a) have a different commit checked out than the one you're pushing or (b) have closed some changed submodules since git-adding them. It doesn't seem obvious to me that "pushing multiple meta commits" is a more common operaton than that (even in a future when we support "assembling" them).

bpeabody commented 6 years ago

How about we push (a) open submodules and (b) any submodules changed in the commit being pushed (opening them if necessary)?

abliss commented 6 years ago

sounds good to me!