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
663d7f3d
Commit
663d7f3d
authored
Jan 30, 2018
by
Guilhem Saurel
Browse files
improve project detail view
parent
6af83b47
Changes
3
Hide whitespace changes
Inline
Side-by-side
rainboard/models.py
View file @
663d7f3d
...
...
@@ -175,11 +175,11 @@ class Project(Links, NamedModel, TimeStampedModel):
return
repo
def
update_branches
(
self
,
main
=
True
):
branches
=
MAIN_BRANCHES
if
main
else
[
b
[
2
:]
for
b
in
self
.
git
().
git
.
branch
(
'-a'
,
'--no-color'
).
split
(
'
\n
'
)]
branches
=
[
b
[
2
:]
for
b
in
self
.
git
().
git
.
branch
(
'-a'
,
'--no-color'
).
split
(
'
\n
'
)]
if
main
:
branches
=
[
b
for
b
in
branches
if
b
.
endswith
(
'master'
)
or
b
.
endswith
(
'devel'
)]
for
branch
in
branches
:
if
branch
in
MAIN_BRANCHES
:
if
branch
not
in
self
.
git
().
heads
:
continue
instance
,
created
=
Branch
.
objects
.
get_or_create
(
name
=
branch
,
project
=
self
)
if
created
:
instance
.
update_ab
()
...
...
@@ -195,6 +195,9 @@ class Project(Links, NamedModel, TimeStampedModel):
if
created
:
instance
.
update_ab
()
def
main_branch
(
self
):
return
'devel'
if
'devel'
in
self
.
git
().
heads
else
'master'
class
Repo
(
TimeStampedModel
):
name
=
models
.
CharField
(
max_length
=
200
)
...
...
@@ -284,6 +287,19 @@ class Repo(TimeStampedModel):
logger
.
info
(
f
'Creating remote
{
remote
}
'
)
return
git
.
create_remote
(
remote
,
self
.
get_clone_url
())
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
''
class
Commit
(
NamedModel
,
TimeStampedModel
):
project
=
models
.
ForeignKey
(
Project
,
on_delete
=
models
.
CASCADE
)
...
...
@@ -302,17 +318,17 @@ class Branch(TimeStampedModel):
unique_together
=
(
'project'
,
'name'
)
def
get_ahead
(
self
,
branch
=
'master'
):
return
len
(
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
self
}
..
{
branch
}
'
).
split
(
'
\n
'
))
return
len
(
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
branch
}
..
{
self
}
'
).
split
(
'
\n
'
))
def
get_behind
(
self
,
branch
=
'master'
):
return
len
(
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
branch
}
..
{
self
}
'
).
split
(
'
\n
'
))
return
len
(
self
.
project
.
git
().
git
.
rev_list
(
f
'
{
self
}
..
{
branch
}
'
).
split
(
'
\n
'
))
def
update_ab
(
self
):
self
.
project
.
main_repo
().
git
().
fetch
()
if
self
.
name
not
in
MAIN_BRANCHES
:
forge
,
namespace
=
self
.
name
.
split
(
'/'
)[:
2
]
Repo
.
objects
.
get
(
forge__slug
=
forge
,
namespace__slug
=
namespace
,
project
=
self
.
project
).
git
().
fetch
()
main_branch
=
'devel'
if
'devel'
in
self
.
project
.
git
().
heads
else
'master'
main_branch
=
self
.
project
.
main_branch
()
self
.
ahead
=
self
.
get_ahead
(
main_branch
)
self
.
behind
=
self
.
get_behind
(
main_branch
)
self
.
save
()
...
...
rainboard/tables.py
View file @
663d7f3d
...
...
@@ -38,6 +38,8 @@ class ProjectTable(StrippedTable):
class
RepoTable
(
StrippedTable
):
diff
=
tables
.
Column
(
accessor
=
'diff'
,
orderable
=
False
)
class
Meta
:
model
=
models
.
Repo
fields
=
(
'forge'
,
'namespace'
,
'license'
,
'homepage'
,
'default_branch'
,
'open_issues'
,
'open_pr'
)
...
...
rainboard/templates/rainboard/project_detail.html
View file @
663d7f3d
...
...
@@ -4,26 +4,40 @@
{% block content %}
<div
class=
"clearfix"
>
{% if project.main_namespace %}
<h2
class=
"pull-right"
>
{{ project.main_namespace }}
</h2>
{% endif %}
<h1>
{{ project }}
</h1>
<div
class=
"pull-right"
>
{% if project.license %}
{% bootstrap_label project.license label_class='label label-primary' %}
{% else %}
{% bootstrap_label 'UNLICENSED' label_class='label label-warning' %}
{% endif %}
{% if project.private %}
{% bootstrap_label 'private' label_class='label label-danger' %}
{% else %}
{% bootstrap_label 'public' label_class='label label-success' %}
{% endif %}
{% if project.license %}
{% bootstrap_label project.license label_class='label label-primary' %}
{% else %}
{% bootstrap_label 'UNLICENSED' label_class='label label-warning' %}
{% endif %}
{% if project.private %}
{% bootstrap_label 'private' label_class='label label-danger' %}
{% else %}
{% bootstrap_label 'public' label_class='label label-success' %}
{% endif %}
</div>
{% if project.homepage %}
<a
href=
"{{ project.homepage }}"
>
{{ project.homepage }}
</a>
{% endif %}
<dl
class=
"dl-horizontal"
>
<dt>
Homepage
</dt>
<dd>
{{ project.homepage|default:"—" }}
</dd>
<dt>
Main forge
</dt>
<dd>
{{ project.main_forge }}
</dd>
<dt>
Main namespace
</dt>
<dd>
{{ project.main_namespace }}
</dd>
<dt>
Main branch
</dt>
<dd>
{{ project.main_branch }}
</dd>
</dl>
</div>
<h2>
Répos
</h2>
{% render_table repos %}
<h2>
Robotpkg
</h2>
{% endblock %}
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