hraban / tomono

Multi- To Mono-repository merge
https://tomono.0brg.net
GNU Affero General Public License v3.0
842 stars 138 forks source link

Switch to ls-remote (branches, tags), copying tags, minor additional updates #39

Closed donkahlero closed 2 years ago

donkahlero commented 3 years ago

Hi guys,

we were using this script to migrate quite a lot of repos into a monorepo. Unfortunately, we noticed some hickups here and there. That's were we decided to use e.g. git ls-remote and other commands to list tags and branches, as well as copying the prior, instead of manipulating/utilizing the git-underlying directory-/file-structure.

Hope these updates are to your liking, otherwise we are more happy to amend!

Cheers, Jonas & Gustaf

hraban commented 3 years ago

Hi Jonas & Gustaf,

This looks lovely, thanks for your patch.

My biggest question is probably around ls-remote: love the idea, looks great, but before I merge this in: what problem exactly does it solve? Which bug does this address?

donkahlero commented 3 years ago

Hi @hraban!

When we migrated our ~80 repos with their 4000+ branches and 1400+ tags in the first place, we noticed that a lot of branches and tags where missing and we could not find them. That's when we first really looked at your script.

We noticed that you were doing some operations on the .git directory and it's contents and this is where the issue with the missing branches and tags stems from.

It is more or less what is pointed out in https://github.com/hraban/tomono/issues/32. That one is fixed by this PR.

gustafj commented 3 years ago

It is also worth noting that usage of the plumbing commands is to be considered as utilizing a stable API suitable for scripting. Which has the added benefit of circumventing all potential problems and issues arising when handling with files within .git directly (e.g. we can ignore if it is stored as a plain file or packed, including any future changes to that representation).

hraban commented 3 years ago

Sounds good. Let me get back to you on this soon.

sirop commented 2 years ago

Have still problems with some tags:

Copying tag Sprint11 over to MyRepo/Sprint11...
Deleted tag 'Sprint11' (was 36d21206)
Copying tag Sprint12 over to MyRepo/Sprint12...
fatal: Failed to resolve 'Sprint12^{}' as a valid ref.
donkahlero commented 2 years ago

Hi @sirop,

how does the merge behave when you use the script from master?

//Jonas

sirop commented 2 years ago

Hello @TacoVox ,

your patch is a definite improvement, as the master version "loses" some branches and files whereas your version does not.

I did not investigate in particular how the master deals with tags, but at least I did not have any (explicit) error messages because of tags.

donkahlero commented 2 years ago

Check. Upon good old-fashioned google, I wonder if you repo is somewhat corrupt.

hraban commented 2 years ago

Hi @TacoVox , this PR got closed by GH as I force pushed an entirely unrelated tree to master. A cleanroom rewrite to get around the licensing issue.

I looked at your changes, and most of them have been taken care of in the rewrite. The one open issue is tags: I'll need to take a look at this, + annotated tags, later. There is an open issue tracking it.

Thanks again for your work 👍

hraban commented 1 year ago

For the record, this was handled in the rewrite when I learned about a way to solve this:

git config --add "remote.$reponame.fetch" "+refs/tags/*:refs/tags/$reponame/*"
git config "remote.$reponame.tagOpt" --no-tags

This automatically namespaces tags.

More info at https://github.com/hraban/tomono#per-repository