Use snake-case naming for functions in git module

parent ba7fc7fa
......@@ -27,7 +27,7 @@ from fabric.utils import abort
import core as c
import helpers as h
from git import isGitDirty
from git import is_git_dirty
@task(alias='make')
......@@ -37,7 +37,7 @@ def make(action='install'):
Build the platform by running the Makefile specified in the local_vars.py configuration file.
"""
if env.get('always_use_pty', True):
if (isGitDirty()):
if (is_git_dirty()):
if (not confirm(red('There are warnings on status of your repositories. '
'Do you want to continue and reset all changes to remote repositories'' states?'), default=False)):
abort('Aborting "drush {}" since there might be a risk of loosing local data.'.format(action))
......
......@@ -18,18 +18,18 @@ def check_status():
"""
Check workspace's git repositories status.
"""
if (isGitDirty()):
if (is_git_dirty()):
print red('Your workspace is not clean.')
else:
print green('Your workspace is clean.')
def isGitDirty():
def is_git_dirty():
repos = local('find ' + path.normpath(env.workspace) + ' -name ".git"', capture=True).splitlines()
nbWarnings = 0
for repo in repos:
repoLocalPath = path.normpath(path.join(repo, '..'))
nbWarnings += _checkRepo(repoLocalPath)
nbWarnings += _check_repo(repoLocalPath)
return (nbWarnings > 0)
......@@ -42,7 +42,7 @@ def isGitDirty():
# - attention aux conflits, faire un pull d'abord et valider la fusion automatique
def _checkRepo(repoLocalPath):
def _check_repo(repoLocalPath):
nbWarnings = 0
with h.fab_cd('local', repoLocalPath):
print green('---')
......@@ -50,21 +50,21 @@ def _checkRepo(repoLocalPath):
remoteName = local('git remote', capture=True)
filesStatusRawInfo = _getFilesStatusInformation()
filesStatusRawInfo = _get_files_status_information()
print green('Verify local files status against current HEAD commit...')
nbWarnings += _checkFilesStatusVsHeadCommit(filesStatusRawInfo)
nbWarnings += _check_files_status_vs_head_commit(filesStatusRawInfo)
localBranchesRawInfo = _getLocalBranchesInformation()
localBranchesRawInfo = _get_local_branches_information()
print green('Verify local branches exist on remote "' + remoteName + '"...');
nbWarnings += _checkLocalBranchesExistOnRemote(localBranchesRawInfo, remoteName)
nbWarnings += _check_local_branches_exist_on_remote(localBranchesRawInfo, remoteName)
print green('Verify branches status against remote...');
nbWarnings += _checkLocalBranchesStatusVsRemote(localBranchesRawInfo, remoteName)
nbWarnings += _check_local_branches_status_vs_remote(localBranchesRawInfo, remoteName)
return nbWarnings
def _checkFilesStatusVsHeadCommit(filesStatusRawInfo):
def _check_files_status_vs_head_commit(filesStatusRawInfo):
nbWarnings = 0
addableFiles = []
if (len(filesStatusRawInfo) > 0):
......@@ -86,12 +86,12 @@ def _checkFilesStatusVsHeadCommit(filesStatusRawInfo):
return nbWarnings
def _checkLocalBranchesExistOnRemote(localBranchesRawInfo, remoteName):
def _check_local_branches_exist_on_remote(localBranchesRawInfo, remoteName):
nbWarnings = 0
pushableBranches = []
for localBranchRawInfo in localBranchesRawInfo:
localBranchName = _getBranchName(localBranchRawInfo)
if ((localBranchName is not None) and (not _remoteBranchExists(localBranchName))):
localBranchName = _get_branch_name(localBranchRawInfo)
if ((localBranchName is not None) and (not _remote_branch_exists(localBranchName))):
nbWarnings += 1
pushableBranches.append(localBranchName)
print yellow('Local branch "' + localBranchName + '" is not present on "' + remoteName + '" remote.')
......@@ -108,7 +108,7 @@ def _checkLocalBranchesExistOnRemote(localBranchesRawInfo, remoteName):
return nbWarnings
def _checkLocalBranchesStatusVsRemote(localBranchesRawInfo, remoteName):
def _check_local_branches_status_vs_remote(localBranchesRawInfo, remoteName):
nbWarnings = 0
pushableBranches = []
# on gere un git FR ou EN, a voir ce qu'on peut faire
......@@ -116,7 +116,7 @@ def _checkLocalBranchesStatusVsRemote(localBranchesRawInfo, remoteName):
pattern = re.compile('.*\[.* (ahead|en avance de) .*\].*')
for localBranchRawInfo in localBranchesRawInfo:
if (pattern.match(localBranchRawInfo)):
localBranchName = _getBranchName(localBranchRawInfo)
localBranchName = _get_branch_name(localBranchRawInfo)
nbWarnings += 1
pushableBranches.append(localBranchName)
print yellow('Local branch "' + localBranchName + '" is ahead of remote branch.');
......@@ -136,26 +136,26 @@ def _checkLocalBranchesStatusVsRemote(localBranchesRawInfo, remoteName):
return nbWarnings
def _getLocalBranchesInformation():
def _get_local_branches_information():
return local('git branch --list -vv', capture=True).splitlines()
def _getBranchName(branchRawData):
def _get_branch_name(branchRawData):
branchName = branchRawData.replace('*', '').strip()
if (_isBranchDetached(branchName)):
if (_is_branch_detached(branchName)):
return None
else:
return branchName.split()[0]
def _isBranchDetached(branchName):
def _is_branch_detached(branchName):
pattern = re.compile('\(.*\)')
return pattern.match(branchName)
def _remoteBranchExists(branchName):
def _remote_branch_exists(branchName):
return (len(local('git branch --list --remote "*' + branchName + '"', capture=True).splitlines()) > 0)
def _getFilesStatusInformation():
def _get_files_status_information():
return local('git status -s', capture=True).splitlines()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment