Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
a0a868b8
Commit
a0a868b8
authored
Sep 26, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into bootstrap
parents
7c22f2c8
278fd4e3
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
99 additions
and
13 deletions
+99
-13
weblate/trans/admin_views.py
weblate/trans/admin_views.py
+4
-1
weblate/trans/formats.py
weblate/trans/formats.py
+3
-0
weblate/trans/models/translation.py
weblate/trans/models/translation.py
+14
-8
weblate/trans/tests/test_vcs.py
weblate/trans/tests/test_vcs.py
+29
-3
weblate/trans/util.py
weblate/trans/util.py
+11
-0
weblate/trans/vcs.py
weblate/trans/vcs.py
+38
-1
No files found.
weblate/trans/admin_views.py
View file @
a0a868b8
...
...
@@ -29,7 +29,7 @@ from weblate import settings_example
from
weblate
import
appsettings
from
weblate.accounts.avatar
import
HAS_LIBRAVATAR
from
weblate.accounts.forms
import
HAS_ICU
from
weblate.trans.util
import
get_configuration_errors
from
weblate.trans.util
import
get_configuration_errors
,
get_clean_env
import
weblate
import
django
...
...
@@ -261,6 +261,7 @@ def generate_ssh_key(request):
'-f'
,
RSA_KEY_FILE
[:
-
4
]
],
stderr
=
subprocess
.
STDOUT
,
env
=
get_clean_env
(),
)
messages
.
success
(
request
,
_
(
'Created new SSH key.'
))
except
(
subprocess
.
CalledProcessError
,
OSError
)
as
exc
:
...
...
@@ -288,6 +289,7 @@ def add_host_key(request):
output
=
subprocess
.
check_output
(
cmdline
,
stderr
=
subprocess
.
STDOUT
,
env
=
get_clean_env
(),
)
keys
=
[
line
...
...
@@ -329,6 +331,7 @@ def ssh(request):
[
'which'
,
'ssh-keygen'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
env
=
get_clean_env
(),
)
can_generate
=
(
ret
==
0
and
not
os
.
path
.
exists
(
RSA_KEY_FILE
))
except
subprocess
.
CalledProcessError
:
...
...
weblate/trans/formats.py
View file @
a0a868b8
...
...
@@ -32,6 +32,7 @@ from translate.storage import mo
from
translate.storage
import
factory
from
weblate.trans.util
import
get_string
,
join_plural
,
add_configuration_error
from
translate.misc
import
quote
from
weblate.trans.util
import
get_clean_env
import
weblate
import
subprocess
import
os.path
...
...
@@ -695,6 +696,7 @@ class PoFormat(FileFormat):
[
'msginit'
,
'--help'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
env
=
get_clean_env
(),
)
cls
.
msginit_found
=
(
ret
==
0
)
except
subprocess
.
CalledProcessError
:
...
...
@@ -727,6 +729,7 @@ class PoFormat(FileFormat):
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
env
=
get_clean_env
(),
)
...
...
weblate/trans/models/translation.py
View file @
a0a868b8
...
...
@@ -28,6 +28,7 @@ from django.core.cache import cache
from
django.utils
import
timezone
from
django.core.urlresolvers
import
reverse
import
os
import
subprocess
import
git
import
traceback
import
ConfigParser
...
...
@@ -49,6 +50,7 @@ from weblate.trans.mixins import URLMixin, PercentMixin
from
weblate.trans.boolean_sum
import
BooleanSum
from
weblate.accounts.models
import
notify_new_string
from
weblate.trans.models.changes
import
Change
from
weblate.trans.util
import
get_clean_env
class
TranslationManager
(
models
.
Manager
):
...
...
@@ -849,15 +851,19 @@ class Translation(models.Model, URLMixin, PercentMixin):
# Pre commit hook
if
self
.
subproject
.
pre_commit_script
!=
''
:
ret
=
os
.
system
(
'%s "%s"'
%
(
self
.
subproject
.
pre_commit_script
,
self
.
get_filename
()
))
if
ret
!=
0
:
try
:
subprocess
.
check_call
(
[
self
.
subproject
.
pre_commit_script
,
self
.
get_filename
()
],
env
=
get_clean_env
(),
)
except
(
OSError
,
subprocess
.
CalledProcessError
)
as
err
:
weblate
.
logger
.
error
(
'Failed to run pre commit script
(%d)
: %s'
,
re
t
,
self
.
subproject
.
pre_commit_script
'Failed to run pre commit script
%s
: %s'
,
self
.
subproject
.
pre_commit_scrip
t
,
err
)
# Create list of files to commit
...
...
weblate/trans/tests/test_vcs.py
View file @
a0a868b8
...
...
@@ -77,11 +77,37 @@ class VCSGitTest(RepoTestCase):
repo
=
GitRepository
.
clone
(
self
.
repo_path
,
self
.
_tempdir
)
self
.
assertFalse
(
repo
.
needs_commit
())
def
test_revision_info
(
self
):
repo
=
GitRepository
.
clone
(
self
.
repo_path
,
self
.
_tempdir
)
info
=
repo
.
get_revision_info
(
repo
.
last_revision
)
def
check_valid_info
(
self
,
info
):
self
.
assertTrue
(
'summary'
in
info
)
self
.
assertTrue
(
'author'
in
info
)
self
.
assertTrue
(
'authordate'
in
info
)
self
.
assertTrue
(
'commit'
in
info
)
self
.
assertTrue
(
'commitdate'
in
info
)
def
test_revision_info
(
self
):
repo
=
GitRepository
.
clone
(
self
.
repo_path
,
self
.
_tempdir
)
# Latest commit
info
=
repo
.
get_revision_info
(
repo
.
last_revision
)
self
.
check_valid_info
(
info
)
# GPG signed commit
info
=
repo
.
get_revision_info
(
'd6179e46c8255f1d5029f06c49468caf57b13b61'
)
self
.
check_valid_info
(
info
)
self
.
assertEquals
(
info
[
'author'
],
'Michal Čihař <michal@cihar.com>'
)
# Normal commit
info
=
repo
.
get_revision_info
(
'2ae1998450a693f0a7962d69a1eec4cb2213d595'
)
self
.
check_valid_info
(
info
)
def
test_needs_merge
(
self
):
repo
=
GitRepository
.
clone
(
self
.
repo_path
,
self
.
_tempdir
)
self
.
assertFalse
(
repo
.
needs_merge
(
'master'
))
self
.
assertFalse
(
repo
.
needs_push
(
'master'
))
weblate/trans/util.py
View file @
a0a868b8
...
...
@@ -24,6 +24,7 @@ from django.core.cache import cache
from
importlib
import
import_module
import
time
import
random
import
os
PLURAL_SEPARATOR
=
'
\
x1e
\
x1e
'
...
...
@@ -144,3 +145,13 @@ def get_configuration_errors():
Returns all configuration errors.
"""
return
cache
.
get
(
'configuration-errors'
,
[])
def
get_clean_env
():
"""
Returns cleaned up environment for subprocess execution.
"""
return
{
'HOME'
:
os
.
environ
[
'HOME'
],
'PATH'
:
os
.
environ
[
'PATH'
],
}
weblate/trans/vcs.py
View file @
a0a868b8
...
...
@@ -22,6 +22,7 @@ Minimal distributed version control system abstraction for Weblate needs.
"""
import
subprocess
from
dateutil
import
parser
from
weblate.trans.util
import
get_clean_env
class
RepositoryException
(
Exception
):
...
...
@@ -38,7 +39,6 @@ class Repository(object):
- repository configuration (SubProject.configure_repo)
- branch configuration (SubProject.configure_branch)
- needs merge/push (SubProject.git_needs_merge/push)
- get object hash (Translation.get_git_blob_hash)
- commit (Translation.__git_commit)
- configuration (Translation.__configure_committer)
...
...
@@ -64,6 +64,7 @@ class Repository(object):
process
=
subprocess
.
Popen
(
args
,
cwd
=
cwd
,
env
=
get_clean_env
(),
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
)
...
...
@@ -143,6 +144,20 @@ class Repository(object):
"""
raise
NotImplementedError
()
def
needs_merge
(
self
,
branch
):
"""
Checks whether repository needs merge with upstream
(is missing some revisions).
"""
raise
NotImplementedError
()
def
needs_push
(
self
,
branch
):
"""
Checks whether repository needs push to upstream
(has additional revisions).
"""
raise
NotImplementedError
()
def
get_revision_info
(
self
,
revision
):
"""
Returns dictionary with detailed revision information.
...
...
@@ -221,3 +236,25 @@ class GitRepository(Repository):
result
[
'summary'
]
=
message
[
0
]
return
result
def
_log_revisions
(
self
,
refspec
):
"""
Returns revisin log for given refspec.
"""
return
self
.
_execute
(
[
'log'
,
'--oneline'
,
refspec
,
'--'
]
)
def
needs_merge
(
self
,
branch
):
"""
Checks whether repository needs merge with upstream
(is missing some revisions).
"""
return
self
.
_log_revisions
(
'..origin/{0}'
.
format
(
branch
))
!=
''
def
needs_push
(
self
,
branch
):
"""
Checks whether repository needs push to upstream
(has additional revisions).
"""
return
self
.
_log_revisions
(
'origin/{0}..'
.
format
(
branch
))
!=
''
Write
Preview
Markdown
is supported
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