Open pboling opened 1 year ago
I set one of the repos in my meta repo linked above as an array with two git repos to see what it would do.
> meta git update
...
/Users/pboling/src/meta/rubocop-lts: command 'git clone git@gitlab.com:rubocop-lts/rubocop-lts.git,git@codeberg.org:rubocop-lts/rubocop-lts.git rubocop-lts' exited with error: Error: Command failed: git clone git@gitlab.com:rubocop-lts/rubocop-lts.git,git@codeberg.org:rubocop-lts/rubocop-lts.git rubocop-lts
That's pretty dense, but the command that ran was:
git clone git@gitlab.com:rubocop-lts/rubocop-lts.git,git@codeberg.org:rubocop-lts/rubocop-lts.git rubocop-lts
And the problem is obviously that it ran a single command with both git repos, instead of the set of commands to add the additional repos after the first as push targets.
interesting - wasn't aware you could have multiple push targets for a remote.
meta-project is mostly just executing commands in child processes, so doesn't sound too difficult to create theoretically
git push all
is my new favorite thing, and I can push to all my DVCS remotes at once!
Found a sequence of commands that may be helpful. Requires grep
and cut
, but those are fairly universal on POSIX machines.
git remote -v | grep origin | grep fetch | cut -w -f2
Used like this:
β― git remote -v
all git@github.com:rubocop-lts/meta.git (fetch)
all git@git.sr.ht:~galtzo/rubocop-lts-meta (push)
all git@github.com:rubocop-lts/meta.git (push)
all git@gitlab.com:rubocop-lts/meta.git (push)
all git@codeberg.org:rubocop-lts/meta.git (push)
origin git@github.com:rubocop-lts/meta.git (fetch)
origin git@github.com:rubocop-lts/meta.git (push)
β― orig=$(git remote -v | grep origin | grep fetch | cut -w -f2)
β― echo $orig
git@github.com:rubocop-lts/meta.git
all is just a name though, right? you could set up origin to push to many as well?
Yeah, correct; technically origin
is just a name as well, just very common due to it being a default value.
π Feature Proposal
DVCS, or Distributed Version Control Systems, like git, allow for code to be hosted in a distributed manner. I am now [beginning to replicate][summary] my projects on 2, 3, 4 (more?!?) different source forges. I am also starting to convert at least one of these projects into a "distributed" meta repo using this tool (π1, π§2, π§ͺ3, π4!).
My goal is for each sub-project to push to an "all" instead of an "origin", where "all" targets several remote repositories.
Motivation
Without this feature it seems that I'll need to not use most of this project's features and run lots of manual commands on each sub-project.
Example
meta git push all
would push to all.Of course I can already do
meta exec git push all
... So this feature request is about how to configure the multi-repo'd projects.Currently we have:
I'd like to have a way to run the necessary commands (as in my summary article [already linked][summary]) to setup the "all" remote with many target repos. Perhaps a new command
distribute
:And that would run something like this:
NOTES:
distribute
is run. If "all" already exists it will just fail that command, as follows:First time around, ^ is fine, as the original is a fetch and push target 1x each.
But, the next time around, it doesn't work so well, so you'd need to test if the original repo is already a push url:
β― git remote set-url --add --push all git://yet-another/repo.git
Somehow detect if the original is already present as a push target, and only add it back if missing.