mixu / gr

Multiple git repository management tool
http://mixu.net/gr/
674 stars 104 forks source link

Expand tilde for $HOME in grconfig.json #42

Open eriknomitch opened 8 years ago

eriknomitch commented 8 years ago

I have multiples machines and I want to share a grconfig.json with all of them as I have a configs git repository. Some of them have different $HOME directories so the full paths required by grconfig.json is unfortunately a bit of a hangup.

I would love to be able to use tilde for $HOME in grconfig.json. Is there any workaround currently? Otherwise, I'm going to have to write a script to generate grconfig.json files for each machine.

Love gr!

Erik

xapple commented 8 years ago

+1 this is really essential to make gr usable and not have to configure it again each time you deploy to a new server.

xapple commented 8 years ago

The worst is that it doesn't even tell you it's a problem so you can search for hours. You just see:

 $ gr git pull
 Skipped  as it does not have a .git subdirectory.
xapple commented 8 years ago

Here is my install script that auto-generates the config file if it can help anyone.

import sh, glob, os
sh.npm('install', '-g', 'git-run')

home = os.environ.get('HOME', '~') + '/'
repo = home + 'repos/'
repos = glob.glob(repo + '*')
path = home + '.grconfig.json'

text =  """
{
  "tags": {
    "all": [
      %s
    ]
  }
}""" % ',\n      '.join(('"%s"' % r for r in repos))
with open(path, 'w') as handle: handle.write(text)