Skip to content

Commit

Permalink
minor small cleanups
Browse files Browse the repository at this point in the history
added a function to call git
  • Loading branch information
Mark Fiers committed Sep 28, 2012
1 parent cbde5f9 commit e8c04a5
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/python/moa/plugin/system/moaGit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""
import glob
import os
import subprocess
import subprocess as sp
import sys
import time

Expand All @@ -22,6 +22,11 @@
from moa.sysConf import sysConf


def _callGit(cl):
moa.ui.message("executing %s" % cl)
return sp.call(cl, shell=True)


def _getRepo(job):
"""
Return the git repository object
Expand All @@ -34,11 +39,12 @@ def _getRepo(job):
except git.InvalidGitRepositoryError:
return None


def _checkInRepo(job):
"""
Check if we're inside a repository
"""
rc = subprocess.call(['git status --porcelain -uno'].split())
rc = sp.call(['git status --porcelain -uno'].split())
if rc == 0:
l.debug("In a git repository (%s)" % job.wd)
return True
Expand Down Expand Up @@ -104,7 +110,7 @@ def _commitDir(wd, message):
if not os.path.exists(moadir):
return

_checkGitIgnore(wd)
#_checkGitIgnore(wd)

files = set()
for gl in sysConf.plugins.system.moaGit.commit:
Expand All @@ -125,7 +131,7 @@ def _commit(job, message):
if not repo:
return

_checkGitIgnore(job.wd)
#_checkGitIgnore(job.wd)

files = []
files.extend(job.getFiles())
Expand Down Expand Up @@ -161,6 +167,7 @@ def hook_prepare_3():
"""
sysConf.git.commit = _commit
sysConf.git.active = True
sysConf.git.callGit = _callGit
sysConf.git.commitJob = _commit
sysConf.git.commitDir = _commitDir
sysConf.git.getRepo = _getRepo
Expand Down Expand Up @@ -193,7 +200,10 @@ def hook_postNew():
if sysConf.job.template.name != 'project':
return

l.warning("Creating a new git repository")
#create a .gitignore file
_checkGitIgnore(sysConf.job.wd)

moa.ui.warn("Creating a new git repository")
sysConf.git.repo = git.Repo.init(sysConf.job.wd)
_commit(sysConf.job, "New Moa Project")

Expand Down

0 comments on commit e8c04a5

Please sign in to comment.