From d7365dd774fb089b53e5d9518f810971c577a06a Mon Sep 17 00:00:00 2001 From: gau1991 Date: Thu, 8 Jan 2015 07:29:30 +0000 Subject: [PATCH] Git function --- ee/core/git.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ee/core/git.py b/ee/core/git.py index 6a61cb91..7a97d15a 100644 --- a/ee/core/git.py +++ b/ee/core/git.py @@ -1,4 +1,5 @@ -"""EasyEngine GIT module""" +from sh import git, ErrorReturnCode +import os class EEGit(): @@ -6,3 +7,24 @@ class EEGit(): def ___init__(): # TODO method for core variables pass + + def add(paths, msg="Intializating"): + for path in paths: + agit = git.bake("--git-dir={0}/.git".format(path), + "--work-tree={0}".format(path)) + if os.path.isdir(path): + if not os.path.isdir(path+"/.git"): + try: + git.init(path) + except ErrorReturnCode as e: + print(e) + sys.exit(1) + status = git.status("-s") + if len(status.splitlines()) > 0: + try: + git.add("--all") + git.commit("-am {0}".format(msg)) + except ErrorReturnCode as e: + print(e) + sys.exit(1) + pass