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
075910b4
Commit
075910b4
authored
Sep 26, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement remote repository configuration
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
d50c3df7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
1 deletion
+60
-1
weblate/trans/tests/test_vcs.py
weblate/trans/tests/test_vcs.py
+18
-0
weblate/trans/vcs.py
weblate/trans/vcs.py
+42
-1
No files found.
weblate/trans/tests/test_vcs.py
View file @
075910b4
...
...
@@ -152,3 +152,21 @@ class VCSGitTest(RepoTestCase):
len
(
obj_hash
),
40
)
def
test_configure_remote
(
self
):
self
.
repo
.
configure_remote
(
'pullurl'
,
'pushurl'
,
'branch'
)
self
.
assertEquals
(
self
.
repo
.
get_config
(
'remote.origin.url'
),
'pullurl'
,
)
self
.
assertEquals
(
self
.
repo
.
get_config
(
'remote.origin.pushURL'
),
'pushurl'
,
)
# Test that we handle not set fetching
self
.
repo
.
_execute
([
'config'
,
'--unset'
,
'remote.origin.fetch'
])
self
.
repo
.
configure_remote
(
'pullurl'
,
'pushurl'
,
'branch'
)
self
.
assertEquals
(
self
.
repo
.
get_config
(
'remote.origin.fetch'
),
'+refs/heads/branch:refs/remotes/origin/branch'
,
)
weblate/trans/vcs.py
View file @
075910b4
...
...
@@ -37,7 +37,6 @@ class Repository(object):
Currently missing methods:
- repository configuration (SubProject.configure_repo)
- branch configuration (SubProject.configure_branch)
"""
_last_revision
=
None
...
...
@@ -187,6 +186,12 @@ class Repository(object):
"""
raise
NotImplementedError
()
def
configure_remote
(
self
,
pull_url
,
push_url
,
branch
):
"""
Configure remote repository.
"""
raise
NotImplementedError
()
class
GitRepository
(
Repository
):
"""
...
...
@@ -335,3 +340,39 @@ class GitRepository(Repository):
Returns hash of object in the VCS.
"""
return
self
.
_execute
([
'ls-tree'
,
'HEAD'
,
path
]).
split
()[
2
]
def
configure_remote
(
self
,
pull_url
,
push_url
,
branch
):
"""
Configure remote repository.
"""
old_pull
=
None
old_push
=
None
# Parse existing remotes
for
remote
in
self
.
_execute
([
'remote'
,
'-v'
]).
splitlines
():
name
,
url
,
kind
=
remote
.
split
()
if
name
!=
'origin'
:
continue
if
kind
==
'(fetch)'
:
old_pull
=
url
elif
kind
==
'(push)'
:
old_push
=
url
if
old_pull
is
None
:
# No origin existing
self
.
_execute
([
'remote'
,
'add'
,
'origin'
,
pull_url
])
elif
old_pull
!=
pull_url
:
# URL changed?
self
.
_execute
([
'remote'
,
'set-url'
,
'origin'
,
pull_url
])
if
old_push
!=
push_url
:
self
.
_execute
([
'remote'
,
'set-url'
,
'origin'
,
'--push'
,
push_url
])
# Set branch to track
try
:
self
.
_execute
(
[
'remote'
,
'set-branches'
,
'origin'
,
branch
]
)
except
RepositoryException
:
self
.
_execute
(
[
'remote'
,
'set-branches'
,
'--add'
,
'origin'
,
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