managing remotes collaboratively with mr

micah anderson micah at riseup.net
Mon May 2 18:50:26 CEST 2011


On Fri, 29 Apr 2011 19:49:49 -0400, Joey Hess <joey at kitenet.net> wrote:
> micah anderson wrote:
> > But what if someone adds a new remote? Because I put things in the
> > .mrconfig as a 'post_checkout' the new remote will not be added to the
> > git repository. I could add the remotes twice, in a post_checkout (for
> > the new person who wants to get them all) and then also as a pre_update,
> > but that seems a bit ugly.
> 
> [DEFAULT]
> post_checkout = mr addremotes
> pre_update = mr addremotes
> 
> [apache]
> checkout = git clone gitosis at labs.riseup.net:shared-apache apache
> addremotes =
> 	git remote add foo git://foo.ch/apache.git
> 	git remote add bar git://bar.net/modules/apache
> 	git remote add baz git://github.com/baz/apache.git

Thanks, that sort of works, but what happens is if I have more than one
repository defined, then the post_checkout is run when the first
repository is checked out, but it is run on every defined
repository. That is a problem because the second repository isn't
checked out yet. It seems the problem is because the 'addremotes' is a
globally defined setting, but locally scoped to the repository. So every
post_checkout will call every repository's defined 'addremotes'
regardless if mr is operating on that repository at that time or not.

Additionally, it seems as if post_checkout and pre_update, even when
defined in a repository section, operate on all defined repositories.

To illustrate, I have this:

[DEFAULT]
post_checkout = mr addremotes
pre_update = mr addremotes

[apache]
checkout = git clone gitosis at labs.riseup.net:shared-apache apache
addremotes = 
        git remote add foo git://foo.ch/apache.git
        git remote add bar git://bar.net/puppet/modules/apache
        git remote add baz git://github.com/baz/apache.git

[apt]
checkout = git clone gitosis at labs.riseup.net:shared-apt apt
addremotes = 
        git remote add foo git://foo.ch/module-apt.git
        git remote add bar git://bar.net/puppet-module-apt.git
        git remote add baz git://github.com/baz/apt


micah at algae:/tmp/modules$ mr checkout
mr checkout: /tmp/modules/apache
Cloning into apache...
remote: Counting objects: 2938, done.
remote: Compressing objects: 100% (908/908), done.
remote: Total 2938 (delta 1753), reused 2938 (delta 1753)
Receiving objects: 100% (2938/2938), 466.73 KiB | 62 KiB/s, done.
Resolving deltas: 100% (1753/1753), done.
mr addremotes: /tmp/modules/apache

mr addremotes: failed to chdir to /tmp/puppet_modules/apt/: No such file or directory

mr addremotes: finished (1 ok; 1 failed)

mr checkout: /tmp/puppet_modules/apt
Cloning into apt...
remote: Counting objects: 1256, done.
remote: Compressing objects: 100% (665/665), done.
remote: Total 1256 (delta 616), reused 1056 (delta 497)
Receiving objects: 100% (1256/1256), 159.54 KiB | 92 KiB/s, done.
Resolving deltas: 100% (616/616), done.
mr addremotes: /tmp/puppet_modules/apache
fatal: remote foo already exists.
mr addremotes: command failed

mr addremotes: /tmp/puppet_modules/apt

mr addremotes: finished (1 ok; 1 failed)

mr checkout: finished (2 ok)
micah at algae:/tmp/puppet_modules$ 

Then when I do an update:

micah at algae:/tmp/puppet_modules$ mr update
mr update: /tmp/puppet_modules/apache
mr addremotes: /tmp/puppet_modules/apache
fatal: remote foo already exists.
mr addremotes: command failed

mr addremotes: finished (1 failed)
Already up-to-date.

mr update: /tmp/puppet_modules/apt
mr addremotes: /tmp/puppet_modules/apt
fatal: remote foo already exists.
mr addremotes: command failed

mr addremotes: finished (1 failed)
Already up-to-date.

mr update: finished (2 ok)

I can add a >2/dev/null to the first 'remote add' in each repository
section, but that just hides the error, and mr still says it fails with
a 'mr addremotes: command failed'. Sure, its not a big deal that the
remote already exists and mr is trying to add it again and it fails, but
the error is something that people are going to notice and ask me about.

If I were to do this:

[DEFAULT]
post_checkout = mr addremotes
pre_update = mr addremotes

[apache]
checkout = git clone gitosis at labs.riseup.net:shared-apache apache
post_checkout = mr apacheremotes
pre_update = mr apacheremotes
apacheremotes = 
        git remote add foo git://foo.ch/apache.git
        git remote add bar git://bar.net/puppet/modules/apache
        git remote add baz git://github.com/baz/apache.git

[apt]
checkout = git clone gitosis at labs.riseup.net:shared-apt apt
post_checkout = mr aptremotes
pre_update = mr aptremotes
aptremotes = 
        git remote add foo git://foo.ch/module-apt.git
        git remote add bar git://bar.net/puppet-module-apt.git
        git remote add baz git://github.com/baz/apt

then each of the post_checkout/pre_update lines defined for each
repository are run on every repository:

micah at algae:/tmp/puppet_modules$ mr checkout
mr checkout: /tmp/puppet_modules/apache
Cloning into apache...
remote: Counting objects: 2938, done.
remote: Compressing objects: 100% (908/908), done.
remote: Total 2938 (delta 1753), reused 2938 (delta 1753)
Receiving objects: 100% (2938/2938), 466.73 KiB | 54 KiB/s, done.
Resolving deltas: 100% (1753/1753), done.
mr apacheremotes: /tmp/puppet_modules/apache

mr apacheremotes: failed to chdir to /tmp/puppet_modules/apt/: No such file or directory

mr apacheremotes: finished (1 ok; 1 failed)

mr checkout: /tmp/puppet_modules/apt
Cloning into apt...
remote: Counting objects: 1256, done.
remote: Compressing objects: 100% (665/665), done.
Receiving objects: 100% (1256/1256), 159.42 KiB | 94 KiB/s, done.
remote: Total 1256 (delta 617), reused 1055 (delta 497)
Resolving deltas: 100% (617/617), done.
mr aptremotes: no defined action for git repository /tmp/puppet_modules/apache, skipping
mr aptremotes: /tmp/puppet_modules/apt

mr aptremotes: finished (1 ok; 1 skipped)

mr checkout: finished (2 ok)
micah at algae:/tmp/puppet_modules$ 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.madduck.net/pipermail/vcs-home/attachments/20110502/5edaa362/attachment.pgp>


More information about the vcs-home mailing list