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
f6cf88c9
Commit
f6cf88c9
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[scripts] Add preliminary color support
parent
35f13db1
No related branches found
No related tags found
1 merge request
!17
Terminal colors
Pipeline
#26967
passed
6 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/devtools/scripts/lasttag.py
+17
-11
17 additions, 11 deletions
bob/devtools/scripts/lasttag.py
bob/devtools/scripts/visibility.py
+8
-9
8 additions, 9 deletions
bob/devtools/scripts/visibility.py
with
25 additions
and
20 deletions
bob/devtools/scripts/lasttag.py
+
17
−
11
View file @
f6cf88c9
#!/usr/bin/env python
#!/usr/bin/env python
import
os
import
os
import
logging
logger
=
logging
.
getLogger
(
__name__
)
import
click
import
click
import
gitlab
from
.
import
bdt
from
.
import
bdt
from
..log
import
verbosity_option
from
..changelog
import
get_last_tag
,
parse_date
from
..changelog
import
get_last_tag
,
parse_date
from
..release
import
get_gitlab_instance
from
..release
import
get_gitlab_instance
from
..log
import
verbosity_option
,
get_logger
,
echo_normal
,
echo_warning
logger
=
get_logger
(
__name__
)
@click.command
(
epilog
=
'''
@click.command
(
epilog
=
'''
Examples:
Examples:
...
@@ -38,11 +39,16 @@ def lasttag(package):
...
@@ -38,11 +39,16 @@ def lasttag(package):
gl
=
get_gitlab_instance
()
gl
=
get_gitlab_instance
()
# we lookup the gitlab package once
# we lookup the gitlab package once
use_package
=
gl
.
projects
.
get
(
package
)
try
:
logger
.
info
(
'
Found gitlab project %s (id=%d)
'
,
use_package
=
gl
.
projects
.
get
(
package
)
use_package
.
attributes
[
'
path_with_namespace
'
],
use_package
.
id
)
logger
.
info
(
'
Found gitlab project %s (id=%d)
'
,
use_package
.
attributes
[
'
path_with_namespace
'
],
use_package
.
id
)
tag
=
get_last_tag
(
use_package
)
date
=
parse_date
(
tag
.
commit
[
'
committed_date
'
])
tag
=
get_last_tag
(
use_package
)
click
.
echo
(
'
Lastest tag for %s is %s (%s)
'
%
\
date
=
parse_date
(
tag
.
commit
[
'
committed_date
'
])
(
package
,
tag
.
name
,
date
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)))
echo_normal
(
'
%s: %s (%s)
'
%
\
(
package
,
tag
.
name
,
date
.
strftime
(
'
%Y-%m-%d %H:%M:%S
'
)))
except
gitlab
.
GitlabGetError
as
e
:
logger
.
warn
(
'
Gitlab access error - package %s does not exist?
'
,
package
)
echo_warning
(
'
%s: unknown
'
%
(
package
,))
This diff is collapsed.
Click to expand it.
bob/devtools/scripts/visibility.py
+
8
−
9
View file @
f6cf88c9
...
@@ -6,13 +6,12 @@ import sys
...
@@ -6,13 +6,12 @@ import sys
import
click
import
click
import
gitlab
import
gitlab
import
logging
logger
=
logging
.
getLogger
(
__name__
)
from
.
import
bdt
from
.
import
bdt
from
..log
import
verbosity_option
from
..release
import
get_gitlab_instance
from
..release
import
get_gitlab_instance
from
..log
import
verbosity_option
,
get_logger
,
echo_normal
,
echo_warning
logger
=
get_logger
(
__name__
)
@click.command
(
epilog
=
'''
@click.command
(
epilog
=
'''
Examples:
Examples:
...
@@ -48,12 +47,12 @@ def visibility(target, group):
...
@@ -48,12 +47,12 @@ def visibility(target, group):
# reads package list or considers name to be a package name
# reads package list or considers name to be a package name
if
os
.
path
.
exists
(
target
)
and
os
.
path
.
isfile
(
target
):
if
os
.
path
.
exists
(
target
)
and
os
.
path
.
isfile
(
target
):
logger
.
info
(
'
Reading package names from file %s...
'
,
target
)
logger
.
debug
(
'
Reading package names from file %s...
'
,
target
)
with
open
(
target
,
'
rt
'
)
as
f
:
with
open
(
target
,
'
rt
'
)
as
f
:
packages
=
[
k
.
strip
()
for
k
in
f
.
readlines
()
if
k
.
strip
()
and
not
\
packages
=
[
k
.
strip
()
for
k
in
f
.
readlines
()
if
k
.
strip
()
and
not
\
k
.
strip
().
startswith
(
'
#
'
)]
k
.
strip
().
startswith
(
'
#
'
)]
else
:
else
:
logger
.
info
(
'
Assuming %s is a package name (file does not
'
\
logger
.
debug
(
'
Assuming %s is a package name (file does not
'
\
'
exist)...
'
,
target
)
'
exist)...
'
,
target
)
packages
=
[
target
]
packages
=
[
target
]
...
@@ -66,11 +65,11 @@ def visibility(target, group):
...
@@ -66,11 +65,11 @@ def visibility(target, group):
# retrieves the gitlab package object
# retrieves the gitlab package object
try
:
try
:
use_package
=
gl
.
projects
.
get
(
package
)
use_package
=
gl
.
projects
.
get
(
package
)
logger
.
info
(
'
Found gitlab project %s (id=%d)
'
,
logger
.
debug
(
'
Found gitlab project %s (id=%d)
'
,
use_package
.
attributes
[
'
path_with_namespace
'
],
use_package
.
id
)
use_package
.
attributes
[
'
path_with_namespace
'
],
use_package
.
id
)
click
.
echo
(
'
%s: %s
'
%
(
package
,
echo_normal
(
'
%s: %s
'
%
(
package
,
use_package
.
attributes
[
'
visibility
'
].
lower
()))
use_package
.
attributes
[
'
visibility
'
].
lower
()))
except
gitlab
.
GitlabGetError
as
e
:
except
gitlab
.
GitlabGetError
as
e
:
logger
.
warn
(
'
Gitlab access error - package %s does not exist?
'
,
logger
.
warn
(
'
Gitlab access error - package %s does not exist?
'
,
package
)
package
)
click
.
echo
(
'
%s: unknown
'
%
(
package
,))
echo_warning
(
'
%s: unknown
'
%
(
package
,))
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