Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Specification Tools
Scripts
Commits
a4c0bec6
Commit
a4c0bec6
authored
1 year ago
by
Miguel Angel Reina Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Fix for determining which clauses are changed
parent
d0869d26
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#131
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
generateChangemarks/changemarks.py
+38
-5
38 additions, 5 deletions
generateChangemarks/changemarks.py
with
38 additions
and
5 deletions
generateChangemarks/changemarks.py
+
38
−
5
View file @
a4c0bec6
...
@@ -113,6 +113,7 @@ def find_all_clauses(progress:Progress, mdLines:list[str]):
...
@@ -113,6 +113,7 @@ def find_all_clauses(progress:Progress, mdLines:list[str]):
clause
.
to_id
=
index
-
1
clause
.
to_id
=
index
-
1
clauses
.
append
(
clause
)
clauses
.
append
(
clause
)
logging
.
debug
(
"
Number of clauses: {len(clauses)}
"
)
return
clauses
return
clauses
class
MR
:
class
MR
:
...
@@ -153,14 +154,15 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
...
@@ -153,14 +154,15 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
if
patched_file
.
source_file
.
startswith
(
"
a/TS
"
):
if
patched_file
.
source_file
.
startswith
(
"
a/TS
"
):
logging
.
debug
(
f
"
Looking at changes in
{
patched_file
.
source_file
}
"
)
logging
.
debug
(
f
"
Looking at changes in
{
patched_file
.
source_file
}
"
)
for
change
in
patched_file
:
for
change
in
patched_file
:
change_start_line
,
change_end_line
,
lines_added
,
lines_removed
=
changeDetails
(
change
)
# Check the previous changed_clause
# Check the previous changed_clause
if
(
changed_clause
.
from_id
<=
change
.
target
_start
)
and
(
changed_clause
.
to_id
>=
(
change
.
target_start
-
1
+
change
.
target_length
)
):
if
(
changed_clause
.
from_id
<=
change_start
_line
)
and
(
changed_clause
.
to_id
+
lines_added
-
lines_removed
>=
change_end_line
):
generateMDforChange
(
progress
,
mdLines
,
changed_clause
,
change
,
outDirectory
,
True
)
generateMDforChange
(
progress
,
mdLines
,
changed_clause
,
change
,
outDirectory
,
True
)
break
break
i
=
0
i
=
0
# Check all clauses
# Check all clauses
for
clause
in
clauses
:
for
clause
in
clauses
:
if
(
clause
.
from_id
<=
change
.
target
_start
)
and
(
clause
.
to_id
>=
(
change
.
target_start
-
1
+
change
.
target_length
)
):
if
(
clause
.
from_id
<=
change_start
_line
)
and
(
clause
.
to_id
+
lines_added
-
lines_removed
>=
change_end_line
):
changed_clause
=
clauses
.
pop
(
i
)
changed_clause
=
clauses
.
pop
(
i
)
changed_clauses
.
append
(
clause
)
changed_clauses
.
append
(
clause
)
generateMDforChange
(
progress
,
mdLines
,
changed_clause
,
change
,
outDirectory
,
False
)
generateMDforChange
(
progress
,
mdLines
,
changed_clause
,
change
,
outDirectory
,
False
)
...
@@ -172,6 +174,30 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
...
@@ -172,6 +174,30 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
return
changed_clauses
return
changed_clauses
def
changeDetails
(
change
)
->
(
int
,
int
,
int
,
int
):
i
=
0
lines_added
=
0
lines_removed
=
0
change_start_line
=
change
.
target_start
change_end_line
=
change_start_line
for
line
in
change
:
if
line
.
is_added
or
line
.
is_removed
:
if
change_start_line
==
change
.
target_start
:
change_start_line
=
change
.
target_start
+
i
change_end_line
=
change_end_line
+
i
else
:
change_end_line
=
change_end_line
+
i
i
=
0
if
line
.
is_added
:
lines_added
=
lines_added
+
1
elif
line
.
is_removed
:
lines_removed
=
lines_removed
+
1
i
=
i
+
1
change_end_line
=
change_end_line
-
lines_removed
return
change_start_line
,
change_end_line
,
lines_added
,
lines_removed
def
generateMDforChange
(
progress
:
Progress
,
mdLines
:
list
[
str
],
changed_clause
:
Clause
,
change
,
outDirectory
:
str
,
existing_clause
:
bool
):
def
generateMDforChange
(
progress
:
Progress
,
mdLines
:
list
[
str
],
changed_clause
:
Clause
,
change
,
outDirectory
:
str
,
existing_clause
:
bool
):
'''
'''
Generate the MD for the clauses that have been modified by the merge request
Generate the MD for the clauses that have been modified by the merge request
...
@@ -198,7 +224,10 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
...
@@ -198,7 +224,10 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
for
element
in
tableElements
:
for
element
in
tableElements
:
if
not
element
.
strip
()
==
''
:
if
not
element
.
strip
()
==
''
:
modifiedElements
.
append
(
"
<span class=
\"
underline
\"
>
"
+
element
.
strip
()
+
"
</span>
"
)
modifiedElements
.
append
(
"
<span class=
\"
underline
\"
>
"
+
element
.
strip
()
+
"
</span>
"
)
modifiedRow
=
"
|
"
+
"
|
"
.
join
(
modifiedElements
)
+
"
|
"
+
"
\n
"
#modifiedRow = "|" + "|".join(modifiedElements) + "|" + "\n"
else
:
modifiedElements
.
append
(
element
)
modifiedRow
=
"
|
"
.
join
(
modifiedElements
)
+
"
\n
"
clauseMDlines
.
insert
(
j
,
modifiedRow
)
clauseMDlines
.
insert
(
j
,
modifiedRow
)
clauseMDlines
.
pop
(
j
+
1
)
clauseMDlines
.
pop
(
j
+
1
)
else
:
else
:
...
@@ -212,13 +241,17 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
...
@@ -212,13 +241,17 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
for
element
in
tableElements
:
for
element
in
tableElements
:
if
not
element
.
strip
()
==
''
:
if
not
element
.
strip
()
==
''
:
modifiedElements
.
append
(
"
~~
"
+
element
.
strip
()
+
"
~~
"
)
modifiedElements
.
append
(
"
~~
"
+
element
.
strip
()
+
"
~~
"
)
modifiedRow
=
"
|
"
+
"
|
"
.
join
(
modifiedElements
)
+
"
|
"
+
"
\n
"
#modifiedRow = "|" + "|".join(modifiedElements) + "|" + "\n"
else
:
modifiedElements
.
append
(
element
)
modifiedRow
=
"
|
"
.
join
(
modifiedElements
)
+
"
\n
"
clauseMDlines
.
insert
(
j
,
modifiedRow
)
clauseMDlines
.
insert
(
j
,
modifiedRow
)
else
:
else
:
clauseMDlines
.
insert
(
j
,
"
~~
"
+
line
.
value
.
strip
()
+
"
~~
"
)
clauseMDlines
.
insert
(
j
,
"
~~
"
+
line
.
value
.
strip
()
+
"
~~
"
)
j
=
j
+
1
j
=
j
+
1
clauseMDlines
.
insert
(
j
,
"
\n\n
<br />
"
)
writeMDFile
(
progress
,
clauseMDlines
,
changed_clause
.
clause_nr
.
replace
(
"
"
,
""
)
+
'
.md
'
,
outDirectory
)
writeMDFile
(
progress
,
clauseMDlines
,
changed_clause
.
clause_nr
.
replace
(
"
"
,
""
)
+
'
.md
'
,
outDirectory
)
def
process
(
document
:
str
,
outDirectory
:
str
,
mr
:
MR
)
->
None
:
def
process
(
document
:
str
,
outDirectory
:
str
,
mr
:
MR
)
->
None
:
...
...
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