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
b2e34f97
Commit
b2e34f97
authored
Feb 19, 2013
by
Stefano Rivera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip existing sub-projects
parent
63128841
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
1 deletion
+42
-1
weblate/trans/management/commands/import_project.py
weblate/trans/management/commands/import_project.py
+15
-1
weblate/trans/tests/test_commands.py
weblate/trans/tests/test_commands.py
+22
-0
weblate/trans/tests/test_models.py
weblate/trans/tests/test_models.py
+5
-0
No files found.
weblate/trans/management/commands/import_project.py
View file @
b2e34f97
...
@@ -27,6 +27,7 @@ import git
...
@@ -27,6 +27,7 @@ import git
import
logging
import
logging
import
os
import
os
import
re
import
re
import
shutil
import
fnmatch
import
fnmatch
logger
=
logging
.
getLogger
(
'weblate'
)
logger
=
logging
.
getLogger
(
'weblate'
)
...
@@ -136,10 +137,16 @@ class Command(BaseCommand):
...
@@ -136,10 +137,16 @@ class Command(BaseCommand):
# Create remaining subprojects sharing git repository
# Create remaining subprojects sharing git repository
for
name
in
names
:
for
name
in
names
:
slug
=
name
if
SubProject
.
objects
.
filter
(
project
=
project
,
name
=
name
,
slug
=
slug
).
exists
():
logger
.
warn
(
'Subproject %s already exists, skipping'
,
name
)
continue
logger
.
info
(
'Creating subproject %s'
,
name
)
logger
.
info
(
'Creating subproject %s'
,
name
)
SubProject
.
objects
.
create
(
SubProject
.
objects
.
create
(
name
=
name
,
name
=
name
,
slug
=
name
,
slug
=
slug
,
project
=
project
,
project
=
project
,
repo
=
sharedrepo
,
repo
=
sharedrepo
,
branch
=
branch
,
branch
=
branch
,
...
@@ -156,6 +163,13 @@ class Command(BaseCommand):
...
@@ -156,6 +163,13 @@ class Command(BaseCommand):
# Create first subproject (this one will get full git repo)
# Create first subproject (this one will get full git repo)
name
=
names
.
pop
()
name
=
names
.
pop
()
if
SubProject
.
objects
.
filter
(
project
=
project
,
name
=
name
).
exists
():
logger
.
warn
(
'Subproject %s already exists, skipping and using it '
'as main subproject'
,
name
)
shutil
.
rmtree
(
workdir
)
return
names
,
'weblate://%s/%s'
%
(
project
.
slug
,
name
)
logger
.
info
(
'Creating subproject %s as main subproject'
,
name
)
logger
.
info
(
'Creating subproject %s as main subproject'
,
name
)
# Rename gitrepository to new name
# Rename gitrepository to new name
...
...
weblate/trans/tests/test_commands.py
View file @
b2e34f97
...
@@ -40,6 +40,28 @@ class ImportTest(RepoTestCase):
...
@@ -40,6 +40,28 @@ class ImportTest(RepoTestCase):
# We should have loaded two subprojects
# We should have loaded two subprojects
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
2
)
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
2
)
def
test_re_import
(
self
):
project
=
self
.
create_project
()
call_command
(
'import_project'
,
'test'
,
self
.
repo_path
,
'master'
,
'**/*.po'
,
)
# We should have loaded two subprojects
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
2
)
# We should load no more subprojects
call_command
(
'import_project'
,
'test'
,
self
.
repo_path
,
'master'
,
'**/*.po'
,
)
self
.
assertEqual
(
project
.
subproject_set
.
count
(),
2
)
def
test_import_against_existing
(
self
):
def
test_import_against_existing
(
self
):
'''
'''
Test importing with a weblate:// URL
Test importing with a weblate:// URL
...
...
weblate/trans/tests/test_models.py
View file @
b2e34f97
...
@@ -73,6 +73,11 @@ class RepoTestCase(TestCase):
...
@@ -73,6 +73,11 @@ class RepoTestCase(TestCase):
# Create repository copy for the test
# Create repository copy for the test
shutil
.
copytree
(
self
.
base_repo_path
,
self
.
repo_path
)
shutil
.
copytree
(
self
.
base_repo_path
,
self
.
repo_path
)
# Remove possibly existing project directory
test_repo_path
=
os
.
path
.
join
(
settings
.
GIT_ROOT
,
'test'
)
if
os
.
path
.
exists
(
test_repo_path
):
shutil
.
rmtree
(
test_repo_path
)
def
create_project
(
self
):
def
create_project
(
self
):
'''
'''
Creates test project.
Creates test project.
...
...
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