Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gepetto
dashboard
Commits
cea9e6e6
Commit
cea9e6e6
authored
Feb 01, 2018
by
Guilhem Saurel
Browse files
fix ahead / behind
parent
dcfb8812
Changes
2
Hide whitespace changes
Inline
Side-by-side
rainboard/models.py
View file @
cea9e6e6
...
...
@@ -327,15 +327,11 @@ class Repo(TimeStampedModel):
def
main_branch
(
self
):
return
self
.
project
.
branch_set
.
get
(
name
=
f
'
{
self
.
git_remote
()
}
/
{
self
.
default_branch
}
'
)
def
diff
(
self
):
branch
=
self
.
main_branch
()
if
branch
.
ahead
and
branch
.
behind
:
return
f
'+
{
branch
.
ahead
}
/ -
{
branch
.
behind
}
'
if
branch
.
ahead
:
return
f
'+
{
branch
.
ahead
}
'
if
branch
.
behind
:
return
f
'-
{
branch
.
behind
}
'
return
''
def
ahead
(
self
):
return
self
.
main_branch
().
ahead
def
behind
(
self
):
return
self
.
main_branch
().
behind
class
Commit
(
NamedModel
,
TimeStampedModel
):
...
...
@@ -356,10 +352,12 @@ class Branch(TimeStampedModel):
unique_together
=
(
'project'
,
'name'
)
def
get_ahead
(
self
,
branch
=
'master'
):
return
len
(
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
branch
}
..
{
self
}
'
).
split
(
'
\n
'
))
commits
=
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
branch
}
..
{
self
}
'
)
return
len
(
commits
.
split
(
'
\n
'
))
if
commits
else
0
def
get_behind
(
self
,
branch
=
'master'
):
return
len
(
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
self
}
..
{
branch
}
'
).
split
(
'
\n
'
))
commits
=
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
self
}
..
{
branch
}
'
)
return
len
(
commits
.
split
(
'
\n
'
))
if
commits
else
0
def
remote
(
self
):
# TODO: ForeignKey to Repo
...
...
rainboard/tables.py
View file @
cea9e6e6
...
...
@@ -41,7 +41,8 @@ class ProjectTable(StrippedTable):
class
RepoTable
(
StrippedTable
):
diff
=
tables
.
Column
(
accessor
=
'diff'
,
orderable
=
False
)
ahead
=
tables
.
Column
(
accessor
=
'ahead'
,
orderable
=
False
)
behind
=
tables
.
Column
(
accessor
=
'behind'
,
orderable
=
False
)
class
Meta
:
model
=
models
.
Repo
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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