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
d4b64c06
Commit
d4b64c06
authored
Jan 17, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify handling of Git repository objects
parent
c8ba957b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
19 deletions
+10
-19
weblate/trans/models.py
weblate/trans/models.py
+10
-19
No files found.
weblate/trans/models.py
View file @
d4b64c06
...
...
@@ -803,19 +803,16 @@ class SubProject(models.Model):
if
self
.
is_repo_link
():
return
self
.
linked_subproject
.
update_remote_branch
(
validate
)
if
gitrepo
is
None
:
gitrepo
=
self
.
git_repo
# Update
logger
.
info
(
'updating repo %s'
,
self
.
__unicode__
())
try
:
try
:
git
repo
.
git
.
remote
(
'update'
,
'origin'
)
self
.
git_
repo
.
git
.
remote
(
'update'
,
'origin'
)
except
git
.
GitCommandError
:
# There might be another attempt on pull in same time
# so we will sleep a bit an retry
time
.
sleep
(
random
.
random
()
*
2
)
git
repo
.
git
.
remote
(
'update'
,
'origin'
)
self
.
git_
repo
.
git
.
remote
(
'update'
,
'origin'
)
except
Exception
as
e
:
logger
.
error
(
'Failed to update Git repo: %s'
,
str
(
e
))
if
validate
:
...
...
@@ -922,10 +919,9 @@ class SubProject(models.Model):
return
False
# Do actual push
gitrepo
=
self
.
git_repo
try
:
logger
.
info
(
'pushing to remote repo %s'
,
self
.
__unicode__
())
git
repo
.
git
.
push
(
'origin'
,
'%s:%s'
%
(
self
.
branch
,
self
.
branch
))
self
.
git_
repo
.
git
.
push
(
'origin'
,
'%s:%s'
%
(
self
.
branch
,
self
.
branch
))
return
True
except
Exception
as
e
:
logger
.
warning
(
'failed push on repo %s'
,
self
.
__unicode__
())
...
...
@@ -953,10 +949,9 @@ class SubProject(models.Model):
self
.
update_remote_branch
()
# Do actual reset
gitrepo
=
self
.
git_repo
try
:
logger
.
info
(
'reseting to remote repo %s'
,
self
.
__unicode__
())
git
repo
.
git
.
reset
(
'--hard'
,
'origin/%s'
%
self
.
branch
)
self
.
git_
repo
.
git
.
reset
(
'--hard'
,
'origin/%s'
%
self
.
branch
)
except
Exception
as
e
:
logger
.
warning
(
'failed reset on repo %s'
,
self
.
__unicode__
())
msg
=
'Error:
\
n
%s'
%
str
(
e
)
...
...
@@ -1119,8 +1114,7 @@ class SubProject(models.Model):
'''
Iterator over translations in filesystem.
'''
gitrepo
=
self
.
git_repo
tree
=
gitrepo
.
tree
()
tree
=
self
.
git_repo
.
tree
()
# Glob files
for
filename
in
self
.
get_mask_matches
():
...
...
@@ -1323,24 +1317,22 @@ class SubProject(models.Model):
return
False
return
True
def
git_check_merge
(
self
,
revision
,
gitrepo
=
None
):
def
git_check_merge
(
self
,
revision
):
'''
Checks whether there are any unmerged commits compared to given
revision.
'''
if
gitrepo
is
None
:
gitrepo
=
self
.
git_repo
status
=
gitrepo
.
git
.
log
(
revision
,
'--'
)
status
=
self
.
git_repo
.
git
.
log
(
revision
,
'--'
)
if
status
==
''
:
# No changes to merge
return
False
return
True
def
git_needs_merge
(
self
):
return
self
.
git_check_merge
(
'..origin/%s'
%
self
.
branch
,
gitrepo
)
return
self
.
git_check_merge
(
'..origin/%s'
%
self
.
branch
)
def
git_needs_push
(
self
):
return
self
.
git_check_merge
(
'origin/%s..'
%
self
.
branch
,
gitrepo
)
return
self
.
git_check_merge
(
'origin/%s..'
%
self
.
branch
)
def
get_file_format
(
self
):
'''
...
...
@@ -1872,8 +1864,7 @@ class Translation(models.Model):
'''
Returns current Git blob hash for file.
'''
gitrepo
=
self
.
git_repo
tree
=
gitrepo
.
tree
()
tree
=
self
.
git_repo
.
tree
()
ret
=
tree
[
self
.
filename
].
hexsha
if
self
.
subproject
.
has_template
():
ret
+=
','
...
...
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