Created
December 22, 2016 15:38
-
-
Save giraldeau/d96a78b977a7e57d3b5fedee59d4980b to your computer and use it in GitHub Desktop.
fabfile for computree svn repos
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
from fabric.api import local | |
import json | |
import os | |
from contextlib import contextmanager | |
@contextmanager | |
def cd(newdir): | |
prevdir = os.getcwd() | |
os.chdir(os.path.expanduser(newdir)) | |
try: | |
yield | |
finally: | |
os.chdir(prevdir) | |
""" | |
Example of configuration file fabfile.json: | |
{ | |
"username": "myuser", | |
} | |
""" | |
config = { | |
"username": os.getenv("USER"), | |
"server": "http://rdinnovation.onf.fr/svn", | |
"repos": [ | |
"computree", | |
"computreedevtools", | |
"plugin-onf", | |
"plugin-arts-free", | |
"plugin-onf-lsis", | |
"plugin-generate", | |
"plugin-toolkit", | |
"plugin-lvox", | |
], | |
} | |
if os.path.exists("fabfile.json"): | |
with open("fabfile.json", "r") as f: | |
data = json.load(f) | |
for k, v in data.items(): | |
config[k] = v | |
print(config) | |
def checkout(): | |
attrs = config.copy() | |
for repo in config["repos"]: | |
if not os.path.exists(repo): | |
attrs["repo"] = repo | |
local("svn checkout --username {username} {server}/{repo} {repo}".format(**attrs)) | |
def update(): | |
attrs = config.copy() | |
for repo in config["repos"]: | |
if os.path.exists(repo): | |
with cd(repo): | |
attrs["repo"] = repo | |
local("svn cleanup") | |
local("svn update --username {username}".format(**attrs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment