Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
f3dd9e6b
Commit
f3dd9e6b
authored
4 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Allow changing the server in badges
parent
53cccaf1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!170
Don't update conda first in bootstrap and Allow changing the server in badges
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/devtools/scripts/badges.py
+39
-18
39 additions, 18 deletions
bob/devtools/scripts/badges.py
with
39 additions
and
18 deletions
bob/devtools/scripts/badges.py
+
39
−
18
View file @
f3dd9e6b
...
...
@@ -18,12 +18,12 @@ logger = get_logger(__name__)
PROJECT_BADGES
=
[
{
"
name
"
:
"
Docs (stable)
"
,
"
link_url
"
:
"
https://www.idiap.ch/software/{group
}/docs/%{{project_path}}/stable/index.html
"
,
"
link_url
"
:
"
{idiap_server
}/docs/%{{project_path}}/stable/index.html
"
,
"
image_url
"
:
"
https://img.shields.io/badge/docs-stable-yellow.svg
"
,
},
{
"
name
"
:
"
Docs (latest)
"
,
"
link_url
"
:
"
https://www.idiap.ch/software/{group
}/docs/%{{project_path}}/%{{default_branch}}/index.html
"
,
"
link_url
"
:
"
{idiap_server
}/docs/%{{project_path}}/%{{default_branch}}/index.html
"
,
"
image_url
"
:
"
https://img.shields.io/badge/docs-latest-orange.svg
"
,
},
{
...
...
@@ -47,9 +47,14 @@ PROJECT_BADGES = [
# These show on the README and will be visible in PyPI
README_BADGES
=
[
{
"
name
"
:
"
Docs (current)
"
,
"
link_url
"
:
"
https://www.idiap.ch/software/{group}/docs/{group}/{name}/master/index.html
"
,
"
image_url
"
:
"
https://img.shields.io/badge/docs-available-orange.svg
"
,
"
name
"
:
"
Docs (stable)
"
,
"
link_url
"
:
"
{idiap_server}/docs/{group}/{name}/stable/index.html
"
,
"
image_url
"
:
"
https://img.shields.io/badge/docs-stable-yellow.svg
"
,
},
{
"
name
"
:
"
Docs (latest)
"
,
"
link_url
"
:
"
{idiap_server}/docs/{group}/{name}/master/index.html
"
,
"
image_url
"
:
"
https://img.shields.io/badge/docs-latest-orange.svg
"
,
},
{
"
name
"
:
"
Pipeline (current)
"
,
...
...
@@ -99,6 +104,11 @@ Examples:
"""
)
@click.argument
(
"
package
"
)
@click.option
(
"
--update-readme/--no-update-readme
"
,
default
=
True
,
help
=
"
Whether to update badges in the readme or not.
"
,
)
@click.option
(
"
-d
"
,
"
--dry-run/--no-dry-run
"
,
...
...
@@ -107,9 +117,14 @@ Examples:
"
(combine with the verbosity flags - e.g. ``-vvv``) to enable
"
"
printing to help you understand what will be done
"
,
)
@click.option
(
"
-s
"
,
"
--server
"
,
help
=
"
The documentation server. Default value is https://www.idiap.ch/software/{group}
"
,
)
@verbosity_option
()
@bdt.raise_on_error
def
badges
(
package
,
dry_run
):
def
badges
(
package
,
update_readme
,
dry_run
,
server
):
"""
Creates stock badges for a project repository
"""
# if we are in a dry-run mode, let's let it be known
...
...
@@ -144,27 +159,33 @@ def badges(package, dry_run):
# creates all stock badges, preserve positions
info
=
dict
(
zip
((
"
group
"
,
"
name
"
),
package
.
split
(
"
/
"
,
1
)))
if
not
server
:
server
=
f
"
https://www.idiap.ch/software/
{
group
}
"
info
[
"
idiap_server
"
]
=
server
[:
-
1
]
if
server
.
endswith
(
"
/
"
)
else
server
for
position
,
badge
in
enumerate
(
PROJECT_BADGES
):
data
=
dict
([(
k
,
v
.
format
(
**
info
))
for
(
k
,
v
)
in
badge
.
items
()])
data
[
"
position
"
]
=
position
logger
.
info
(
"
Creating badge
'
%s
'
=>
'
%s
'"
,
data
[
"
name
"
],
data
[
"
link_url
"
],
"
Creating badge
'
%s
'
=>
'
%s
'"
,
data
[
"
name
"
],
data
[
"
link_url
"
],
)
if
not
dry_run
:
use_package
.
badges
.
create
(
data
)
# download and edit README to setup badges
readme_file
=
use_package
.
files
.
get
(
file_path
=
"
README.rst
"
,
ref
=
"
master
"
)
readme_content
=
readme_file
.
decode
().
decode
()
readme_content
=
_update_readme
(
readme_content
,
info
)
# commit and push changes
logger
.
info
(
"
Changing README.rst badges...
"
)
update_files_at_master
(
use_package
,
{
"
README.rst
"
:
readme_content
},
"
Updated badges section [ci skip]
"
,
dry_run
,
)
if
update_readme
:
readme_file
=
use_package
.
files
.
get
(
file_path
=
"
README.rst
"
,
ref
=
"
master
"
)
readme_content
=
readme_file
.
decode
().
decode
()
readme_content
=
_update_readme
(
readme_content
,
info
)
# commit and push changes
logger
.
info
(
"
Changing README.rst badges...
"
)
update_files_at_master
(
use_package
,
{
"
README.rst
"
:
readme_content
},
"
Updated badges section [ci skip]
"
,
dry_run
,
)
logger
.
info
(
"
All done.
"
)
except
gitlab
.
GitlabGetError
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment