Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IP Analysis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
Technology
Eclipse Dash
IP Analysis
Commits
ea78cc22
Commit
ea78cc22
authored
1 month ago
by
André Gomes
Browse files
Options
Downloads
Patches
Plain Diff
Optimize logic for GitLab URL parsing
parent
d6ab14e2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
src/eclipse/ipa/glab/remote.py
+19
-9
19 additions, 9 deletions
src/eclipse/ipa/glab/remote.py
with
20 additions
and
10 deletions
pyproject.toml
+
1
−
1
View file @
ea78cc22
...
...
@@ -23,7 +23,7 @@ description = "A package to perform IP Analysis for GitHub and GitLab projects"
readme
=
"README.md"
license
=
{
text
=
"EPL-2.0"
}
requires-python
=
">
=
3.9
"
dependencies
=
["chardet=
=
5.2
.
0
", "
Jinja2=
=
3.1
.
6
", "
python-gitlab=
=
6.1
.
0
", "
PyGithub=
=
2.6
.
1
"]
dependencies
=
["chardet=
=
5.2
.
0
", "
Jinja2=
=
3.1
.
6
",
"
PyGithub=
=
2.6
.
1
",
"
python-gitlab=
=
6.1
.
0
", "
requests=
=
2.32
.
4
"]
classifiers
=
[
"Programming Language :: Python :: 3"
,
"License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)"
,
...
...
This diff is collapsed.
Click to expand it.
src/eclipse/ipa/glab/remote.py
+
19
−
9
View file @
ea78cc22
...
...
@@ -20,6 +20,7 @@ from datetime import datetime
from
pathlib
import
Path
from
subprocess
import
PIPE
,
Popen
from
time
import
sleep
from
urllib.parse
import
urlparse
import
gitlab
...
...
@@ -39,8 +40,9 @@ def get_dependency_locations(gl, config, repositories):
line_count
=
0
for
repo
in
repositories
:
# From URL to ID (required by python-gitlab)
repo
=
repo
.
replace
(
config
.
get
(
'
General
'
,
'
GitlabURL
'
,
fallback
=
'
https://gitlab.eclipse.org
'
)
+
'
/
'
,
''
)
repo
=
repo
.
replace
(
'
.git
'
,
''
)
repo
=
urlparse
(
repo
).
path
.
lstrip
(
'
/
'
).
removesuffix
(
'
.git
'
)
# Remove any trailing slashes
repo
=
repo
.
rstrip
(
'
/
'
)
dependency_locations
[
repo
]
=
{}
line_count
=
line_count
+
1
...
...
@@ -63,8 +65,9 @@ def get_dependency_locations(gl, config, repositories):
tokens
=
line
.
strip
().
split
(
'
;
'
)
proj_id
=
tokens
[
0
]
# Get rid of base URL, if included (required by python-gitlab)
proj_id
=
proj_id
.
replace
(
config
.
get
(
'
General
'
,
'
GitlabURL
'
,
fallback
=
'
https://gitlab.eclipse.org
'
)
+
'
/
'
,
''
)
proj_id
=
urlparse
(
proj_id
).
path
.
lstrip
(
'
/
'
).
removesuffix
(
'
.git
'
)
# Remove any trailing slashes
proj_id
=
proj_id
.
rstrip
(
'
/
'
)
try
:
dependency_locations
[
proj_id
][
tokens
[
2
]].
append
(
tokens
[
1
])
except
KeyError
:
...
...
@@ -88,8 +91,9 @@ def get_dependency_locations(gl, config, repositories):
line_count
=
line_count
+
1
proj_id
=
line
.
strip
()
# Get rid of base URL, if included (required by python-gitlab)
proj_id
=
proj_id
.
replace
(
config
.
get
(
'
General
'
,
'
GitlabURL
'
,
fallback
=
'
https://gitlab.eclipse.org
'
)
+
'
/
'
,
''
)
proj_id
=
urlparse
(
proj_id
).
path
.
lstrip
(
'
/
'
).
removesuffix
(
'
.git
'
)
# Remove any trailing slashes
proj_id
=
proj_id
.
rstrip
(
'
/
'
)
dependency_locations
[
proj_id
]
=
{}
print
(
"
Read
"
+
str
(
line_count
)
+
"
project(s) from
"
+
input_file
)
logger
.
info
(
"
Read
"
+
str
(
line_count
)
+
"
project(s) from
"
+
input_file
)
...
...
@@ -101,8 +105,10 @@ def get_dependency_locations(gl, config, repositories):
elif
config
.
has_option
(
'
Groups
'
,
'
BaseGroupID
'
):
# Get rid of base URL, if included in BaseGroupID (required by python-gitlab)
base_group_id
=
config
.
get
(
'
Groups
'
,
'
BaseGroupID
'
)
base_group_id
=
base_group_id
.
replace
(
config
.
get
(
'
General
'
,
'
GitlabURL
'
,
fallback
=
'
https://gitlab.eclipse.org
'
)
+
'
/
'
,
''
)
base_group_id
=
urlparse
(
base_group_id
).
path
.
lstrip
(
'
/
'
)
# Remove any trailing slashes
base_group_id
=
base_group_id
.
rstrip
(
'
/
'
)
try
:
# Set base group ID to work
base_group
=
gl
.
groups
.
get
(
base_group_id
,
lazy
=
True
)
...
...
@@ -132,7 +138,11 @@ def get_dependency_locations(gl, config, repositories):
dependency_locations
[
proj
.
path_with_namespace
]
=
{}
# Work with a single project ID
elif
config
.
has_option
(
'
Projects
'
,
'
SingleProjectID
'
):
dependency_locations
[
config
.
get
(
'
Projects
'
,
'
SingleProjectID
'
)]
=
{}
# Get rid of base URL, if included (required by python-gitlab)
repo
=
urlparse
(
config
.
get
(
'
Projects
'
,
'
SingleProjectID
'
)).
path
.
lstrip
(
'
/
'
).
removesuffix
(
'
.git
'
)
# Remove any trailing slashes
repo
=
repo
.
rstrip
(
'
/
'
)
dependency_locations
[
repo
]
=
{}
else
:
# No valid option provided, exit
print
(
"
Insufficient parameters provided. Exiting...
"
)
...
...
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