Created
March 26, 2015 19:14
-
-
Save pradal/a2cd1f7afa3ffb26d431 to your computer and use it in GitHub Desktop.
goat : git for openalea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Classical git command to manage OpenAlea workflow | |
Example | |
======= | |
>>> cd mydir | |
>>> user('pradal', gforge='cpradal') | |
>>> clone('openalea') | |
>>> remote('openalea') | |
INSTALL | |
======= | |
pip install path.py | |
""" | |
import os | |
from path import path | |
_github = None | |
_gforge = None | |
def user(github, gforge=None): | |
global _github, _gforge | |
_github = github | |
_gforge = gforge | |
def abort(login): | |
if login is None: | |
msg = 'create a user first' | |
raise ValueError(msg) | |
def sh(cmd): | |
print cmd | |
return os.system(cmd) | |
def clone(pkg): | |
abort(_github) | |
cmd = 'git clone https://github.com/%s/' % (_github) + pkg | |
print cmd | |
sh(cmd) | |
def clone_gforge(pkg, pkg2=None): | |
abort(_gforge) | |
if pkg2 is None: | |
pkg2 = pkg | |
cmd = 'git clone git+ssh://%s@scm.gforge.inria.fr//gitroot/%s/%s.git' % (_gforge, pkg, pkg2) | |
sh(cmd) | |
def remote(pkg): | |
cwd = path('.').abspath() | |
d = cwd / pkg | |
d.chdir() | |
cmd = 'git remote add upstream https://github.com/openalea/' + pkg | |
sh(cmd) | |
cmd = 'git fetch upstream' | |
sh(cmd) | |
cwd.chdir() | |
def update(pkg): | |
cwd = path('.').abspath() | |
d = cwd / pkg | |
d.chdir() | |
sh('git checkout master') | |
sh('git push upstream/master') | |
sh('git pull') | |
cwd.chdir() | |
pkgs = """ | |
sconsx | |
PkgIt | |
""".split() | |
gforge_pkgs = """ | |
#tissue | |
marsalt | |
""".split() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment