Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Drupal
drupalizer
Commits
969fa8d6
Commit
969fa8d6
authored
Jul 18, 2016
by
Philippe Mouchel
Browse files
More and more refactoring
parent
ea0270ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
git.py
View file @
969fa8d6
...
@@ -45,38 +45,54 @@ def _checkRepo(repoLocalPath):
...
@@ -45,38 +45,54 @@ def _checkRepo(repoLocalPath):
remoteName
=
local
(
'git remote'
,
capture
=
True
)
remoteName
=
local
(
'git remote'
,
capture
=
True
)
remoteURL
=
local
(
'git remote get-url '
+
remoteName
,
capture
=
True
)
remoteURL
=
local
(
'git remote get-url '
+
remoteName
,
capture
=
True
)
print
green
(
'Verify local branches exist on remote "'
+
remoteName
+
'" (URL: '
+
remoteURL
+
')...'
);
localBranchesRawInfo
=
_getLocalBranchesInformation
()
localBranchesRawInfo
=
_getLocalBranchesInformation
()
for
localBranchRawInfo
in
localBranchesRawInfo
:
filesStatusRawInfo
=
_getFilesStatusInformation
()
localBranchName
=
_getBranchName
(
localBranchRawInfo
)
if
((
localBranchName
is
not
None
)
and
(
not
_remoteBranchExists
(
localBranchName
))):
print
green
(
'Verify local branches exist on remote "'
+
remoteName
+
'" (URL: '
+
remoteURL
+
')...'
);
nbWarnings
+=
1
nbWarnings
+=
_checkLocalBranchesExistOnRemote
(
localBranchesRawInfo
)
print
yellow
(
'Local branch "'
+
localBranchName
+
'" is not present on "'
+
remoteName
+
'" remote.'
)
print
green
(
'Verify branches status against remote...'
);
print
green
(
'Verify branches status against remote...'
);
pattern
=
re
.
compile
(
'.*\[.* ahead .*\].*'
)
nbWarnings
+=
_checkLocalBranchesStatusVsRemote
(
localBranchesRawInfo
)
for
localBranchRawInfo
in
localBranchesRawInfo
:
if
(
pattern
.
match
(
localBranchRawInfo
)):
nbWarnings
+=
1
print
yellow
(
'Local branch "'
+
_getBranchName
(
localBranchRawInfo
)
+
'" is ahead of remote branch.'
);
print
green
(
'Verify local files status against current HEAD commit...'
)
print
green
(
'Verify local files status against current HEAD commit...'
)
filesStatusRawInfo
=
_getFilesStatusInformation
()
nbWarnings
+=
_checkFilesStatusVsHeadCommit
(
filesStatusRawInfo
)
if
(
len
(
filesStatusRawInfo
)
>
0
):
for
fileStatus
in
filesStatusRawInfo
:
fileStatusData
=
fileStatus
.
split
()
# Break loop if filename is "fabfile"
if
fileStatusData
[
1
]
==
'fabfile'
:
break
nbWarnings
+=
1
print
yellow
(
'File "'
+
fileStatusData
[
1
]
+
'" '
+
{
'M'
:
'has un-commited modifications.'
,
'??'
:
'is not indexed.'
,
}.
get
(
fileStatusData
[
0
],
'is in an unknown state ('
+
fileStatusData
[
0
]
+
')'
))
return
nbWarnings
return
nbWarnings
def
_checkLocalBranchesExistOnRemote
(
localBranchesRawInfo
):
nbWarnings
=
0
for
localBranchRawInfo
in
localBranchesRawInfo
:
localBranchName
=
_getBranchName
(
localBranchRawInfo
)
if
((
localBranchName
is
not
None
)
and
(
not
_remoteBranchExists
(
localBranchName
))):
nbWarnings
+=
1
print
yellow
(
'Local branch "'
+
localBranchName
+
'" is not present on "'
+
remoteName
+
'" remote.'
)
return
nbWarnings
def
_checkLocalBranchesStatusVsRemote
(
localBranchesRawInfo
):
nbWarnings
=
0
pattern
=
re
.
compile
(
'.*\[.* ahead .*\].*'
)
for
localBranchRawInfo
in
localBranchesRawInfo
:
if
(
pattern
.
match
(
localBranchRawInfo
)):
nbWarnings
+=
1
print
yellow
(
'Local branch "'
+
_getBranchName
(
localBranchRawInfo
)
+
'" is ahead of remote branch.'
);
return
nbWarnings
def
_checkFilesStatusVsHeadCommit
(
filesStatusRawInfo
):
nbWarnings
=
0
if
(
len
(
filesStatusRawInfo
)
>
0
):
for
fileStatus
in
filesStatusRawInfo
:
fileStatusData
=
fileStatus
.
split
()
# Break loop if filename is "fabfile"
if
fileStatusData
[
1
]
==
'fabfile'
:
break
nbWarnings
+=
1
print
yellow
(
'File "'
+
fileStatusData
[
1
]
+
'" '
+
{
'M'
:
'has un-commited modifications.'
,
'??'
:
'is not indexed.'
,
}.
get
(
fileStatusData
[
0
],
'is in an unknown state ('
+
fileStatusData
[
0
]
+
')'
))
return
nbWarnings
def
_getLocalBranchesInformation
():
def
_getLocalBranchesInformation
():
return
local
(
'git branch --list -vv'
,
capture
=
True
).
splitlines
()
return
local
(
'git branch --list -vv'
,
capture
=
True
).
splitlines
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment