Skip to content
GitLab
Menu
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
cb5fc7a0
Commit
cb5fc7a0
authored
Jan 30, 2018
by
Guilhem Saurel
Browse files
parse CMakeLists
parent
663d7f3d
Changes
5
Hide whitespace changes
Inline
Side-by-side
rainboard/management/commands/cmake.py
0 → 100644
View file @
cb5fc7a0
from
django.core.management.base
import
BaseCommand
from
rainboard.models
import
Project
class
Command
(
BaseCommand
):
help
=
'Get informations from CMakeLists.txt on all projects'
def
handle
(
self
,
*
args
,
**
options
):
for
project
in
Project
.
objects
.
all
():
project
.
cmake
()
rainboard/migrations/0008_project_description.py
0 → 100644
View file @
cb5fc7a0
# Generated by Django 2.0.1 on 2018-01-30 17:12
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rainboard'
,
'0007_auto_20180130_1457'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'project'
,
name
=
'description'
,
field
=
models
.
TextField
(
default
=
''
),
preserve_default
=
False
,
),
]
rainboard/migrations/0009_project_version.py
0 → 100644
View file @
cb5fc7a0
# Generated by Django 2.0.1 on 2018-01-30 17:13
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rainboard'
,
'0008_project_description'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'project'
,
name
=
'version'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
20
,
null
=
True
),
),
]
rainboard/models.py
View file @
cb5fc7a0
import
logging
import
re
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.conf
import
settings
...
...
@@ -16,6 +17,7 @@ from .utils import SOURCES, TARGETS, slugify_with_dots
logger
=
logging
.
getLogger
(
'rainboard.models'
)
MAIN_BRANCHES
=
[
'master'
,
'devel'
]
CMAKE_FIELDS
=
{
'name'
:
'name'
,
'description'
:
'description'
,
'url'
:
'homepage'
,
'version'
:
'version'
}
class
Article
(
NamedModel
):
...
...
@@ -154,13 +156,18 @@ class Project(Links, NamedModel, TimeStampedModel):
license
=
models
.
ForeignKey
(
License
,
on_delete
=
models
.
SET_NULL
,
blank
=
True
,
null
=
True
)
homepage
=
models
.
URLField
(
max_length
=
200
,
blank
=
True
,
null
=
True
)
articles
=
models
.
ManyToManyField
(
Article
)
description
=
models
.
TextField
()
version
=
models
.
CharField
(
max_length
=
20
,
blank
=
True
,
null
=
True
)
# TODO: release github ↔ robotpkg
def
get_absolute_url
(
self
):
return
reverse
(
'rainboard:project'
,
kwargs
=
{
'slug'
:
self
.
slug
})
def
git_path
(
self
):
return
settings
.
RAINBOARD_GITS
/
self
.
main_namespace
.
slug
/
self
.
slug
def
git
(
self
):
path
=
se
ttings
.
RAINBOARD_GITS
/
self
.
main_namespace
.
slug
/
self
.
slug
path
=
se
lf
.
git_path
()
if
not
path
.
exists
():
logger
.
info
(
f
'Creating repo for
{
self
.
main_namespace
.
slug
}
/
{
self
.
slug
}
'
)
return
git
.
Repo
.
init
(
path
)
...
...
@@ -198,6 +205,18 @@ class Project(Links, NamedModel, TimeStampedModel):
def
main_branch
(
self
):
return
'devel'
if
'devel'
in
self
.
git
().
heads
else
'master'
def
cmake
(
self
):
filename
=
self
.
git_path
()
/
'CMakeLists.txt'
if
not
filename
.
exists
():
return
with
filename
.
open
()
as
f
:
content
=
f
.
read
()
for
key
,
value
in
CMAKE_FIELDS
.
items
():
search
=
re
.
search
(
f
'set\s*\(\s*project_
{
key
}
\s+([^)]+)*\)'
,
content
,
re
.
I
)
if
search
:
self
.
__dict__
[
value
]
=
search
.
groups
()[
0
].
strip
(
'''
\r\n\t
'"'''
)
self
.
save
()
class
Repo
(
TimeStampedModel
):
name
=
models
.
CharField
(
max_length
=
200
)
...
...
rainboard/templates/rainboard/project_detail.html
View file @
cb5fc7a0
...
...
@@ -20,17 +20,13 @@
{% 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>
<dt>
Main forge
</dt>
<dd>
{{ project.main_forge.get_link }}
</dd>
<dt>
Main namespace
</dt>
<dd>
{{ project.main_namespace }}
</dd>
<dt>
Main branch
</dt>
<dd>
{{ project.main_branch }}
</dd>
<dt>
Description
</dt>
<dd>
{{ project.description }}
</dd>
<dt>
Version
</dt>
<dd>
{{ project.version|default:"—" }}
</dd>
<dt>
Homepage
</dt>
<dd>
{% if project.homepage %}
<a
href=
"{{ project.homepage }}"
>
{{ project.homepage }}
</a>
{% else %}—{% endif %}
</dd>
</dl>
</div>
...
...
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