Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 38 commits into from

Conversation

donkahlero
Copy link

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 and others added 30 commits January 11, 2016 20:35
Set to master and checkout working dir after run
* Support branch names that contain slashes

* Fix 'allow unrelated histories'
…n converting many projects into a mono repo takes a long time)
README: Explain parallel development and merging
Directly list branches from .git meta dir instead of using porcelain
commands. I would have preferred a plumbing command for this but I can't
find any.

Fixes hraban#11
Set monorepo name through envvar (default: "core")
This time I've really dunnit. This should really be it, finally. Finally
finally finally. No more madness with the branches.

Honestly though this was a regression and it might be time to add a
proper test suite :(

But that's for another time! #yolomerge.
Does what it says on the tin. Remote `foo` with tags `v1` and `v2` get
imported as tags `foo/v1` and `foo/v2`.
Add git version to requirements
redthor and others added 8 commits April 9, 2018 12:20
Tags and branches are now read from the corresponding remote, as not
all were found utilizing the ls-files approach.

Furthermore, the tags are now properly copied step by step using
for-each-refs.

Co-authored-by:  gustafj <gustaf@pinon.se>
To be aligned with widely-used tools such as GitLab und GitHub.
@hraban
Copy link
Owner

hraban commented Jul 15, 2021

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
Copy link
Author

donkahlero commented Jul 16, 2021

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 #32. That one is fixed by this PR.

@gustafj
Copy link

gustafj commented Aug 13, 2021

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
Copy link
Owner

hraban commented Aug 14, 2021

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

@sirop
Copy link

sirop commented Jan 5, 2022

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
Copy link
Author

Hi @sirop,

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

//Jonas

@sirop
Copy link

sirop commented Jan 11, 2022

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
Copy link
Author

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

@hraban
Copy link
Owner

hraban commented Jun 22, 2022

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
Copy link
Owner

hraban commented Dec 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants