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
2d007b7d
Commit
2d007b7d
authored
1 year ago
by
Miguel Angel Reina Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Clean up + dealing with code block
parent
d2f882b3
No related branches found
No related tags found
No related merge requests found
Pipeline
#777
passed
1 year ago
Stage: build
Stage: upgrade
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
generateChangemarks/changemarks.py
+33
-13
33 additions, 13 deletions
generateChangemarks/changemarks.py
with
33 additions
and
13 deletions
generateChangemarks/changemarks.py
+
33
−
13
View file @
2d007b7d
...
...
@@ -362,14 +362,13 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
logging
.
debug
(
f
"
Looking at changes in
{
patched_file
.
source_file
}
"
)
lines_added
=
0
lines_removed
=
0
previous_change_lines_added
=
0
for
change
in
patched_file
:
logging
.
debug
(
f
'
Change from patch details: source_start:
{
change
.
source_start
}
- target_start:
{
change
.
target_start
}
'
)
while
index_source
<
change
.
source_start
:
if
mdLines
[
index_source
-
1
].
startswith
(
"
#
"
):
spec_with_changes
.
append
((
mdLines
[
index_source
-
1
]
+
"
\n\n
"
,
False
))
spec_with_changes
.
append
((
mdLines
[
index_source
-
1
]
.
strip
()
+
"
\n\n
"
,
False
))
else
:
spec_with_changes
.
append
((
mdLines
[
index_source
-
1
]
+
"
\n
"
,
False
))
spec_with_changes
.
append
((
mdLines
[
index_source
-
1
].
strip
()
+
"
\n
"
,
False
))
index_source
+=
1
# Sanity check
...
...
@@ -393,15 +392,22 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
change_lines_removed
+=
1
else
:
if
line
.
value
.
startswith
(
"
#
"
):
spec_with_changes
.
append
((
line
.
value
+
"
\n\n
"
,
False
))
spec_with_changes
.
append
((
line
.
value
.
strip
()
+
"
\n\n
"
,
False
))
else
:
spec_with_changes
.
append
((
line
.
value
+
"
\n
"
,
False
))
spec_with_changes
.
append
((
line
.
value
.
strip
()
+
"
\n
"
,
False
))
#spec_with_changes.append((mdLines[index_source-1], False))
index_source
+=
1
lines_added
+=
change_lines_added
lines_removed
+=
change_lines_removed
while
index_source
<
len
(
mdLines
):
if
mdLines
[
index_source
-
1
].
startswith
(
"
#
"
):
spec_with_changes
.
append
((
mdLines
[
index_source
-
1
].
strip
()
+
"
\n\n
"
,
False
))
else
:
spec_with_changes
.
append
((
mdLines
[
index_source
-
1
].
strip
()
+
"
\n
"
,
False
))
index_source
+=
1
logging
.
debug
(
f
'
Applied changes. Total added lines:
{
lines_added
}
.Total removed lines
{
lines_removed
}
'
)
return
spec_with_changes
...
...
@@ -458,9 +464,9 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st
_taskID
=
progress
.
add_task
(
'
[blue]Find clauses with changes
'
,
start
=
False
,
total
=
0
)
clauseregex
=
re
.
compile
(
'
^#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w*(\.\d+)*).*
'
)
removedclauseregex
=
re
.
compile
(
'
^\~\~#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+\s\w*(\.\d+)*).*
'
)
addedclauseregex
=
re
.
compile
(
'
^\<span\sclass\=
\"
underline
\"
\>#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+\s\w*(\.\d+)*).*
'
)
clauseregex
=
re
.
compile
(
'
^#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w
+(\s\w*)
*(\.\d+)*).*
'
)
removedclauseregex
=
re
.
compile
(
'
^\~\~#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+
(
\s\w*
)*
(\.\d+)*).*
'
)
addedclauseregex
=
re
.
compile
(
'
^\<span\sclass\=
\"
underline
\"
\>#+\s(\d+(\.\d+)*|Annex \w(\.\d+)*|\w+
(
\s\w*
)*
(\.\d+)*).*
'
)
clauses
:
list
[
Clause
]
=
[]
changed_clauses
:
list
[
Clause
]
=
[]
...
...
@@ -479,6 +485,7 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st
def
checkClause
(
_matches
):
nonlocal
clause
nonlocal
changeInClause
nonlocal
change
if
index
-
2
==
clause
.
from_id
:
# It is a subclause
clause
.
from_id
=
index
...
...
@@ -490,13 +497,18 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st
if
changeInClause
:
changed_clauses
.
append
(
clause
)
clause
=
Clause
(
line
,
index
,
index
,
_matches
[
0
][
0
])
changeInClause
=
Fals
e
changeInClause
=
chang
e
index
=
1
ignoreRemovedmatches
=
False
ignoreAddedmatches
=
False
inCode
=
False
for
line
,
change
in
mdLines_changes
:
if
change
:
changeInClause
=
True
if
line
.
startswith
(
'
#
'
)
or
line
.
startswith
(
"
~~#
"
)
or
line
.
startswith
(
"
<span class=
\"
underline
\"
>#
"
):
if
line
.
startswith
((
"
```
"
,
"
<span class=
\"
underline
\"
>```
"
)):
inCode
=
not
inCode
if
line
.
startswith
((
'
#
'
,
"
~~#
"
,
"
<span class=
\"
underline
\"
>#
"
),
0
)
and
not
inCode
:
matches
=
re
.
findall
(
clauseregex
,
line
)
# Match heading
removedmatches
=
re
.
findall
(
removedclauseregex
,
line
)
# Match removed heading
addedmatches
=
re
.
findall
(
addedclauseregex
,
line
)
# Match removed heading
...
...
@@ -504,16 +516,24 @@ def find_clauses_with_changes(progress: Progress, mdLines_changes: list[Tuple[st
if
matches
:
# It may be the end of the clause or the start of a subclause
checkClause
(
matches
)
elif
removedmatches
:
if
not
ignoreRemovedmatches
:
checkClause
(
removedmatches
)
ignoreAddedmatches
=
True
else
:
ignoreRemovedmatches
=
False
elif
addedmatches
:
if
not
ignoreAddedmatches
:
checkClause
(
addedmatches
)
ignoreRemovedmatches
=
True
else
:
ignoreAddedmatches
=
False
else
:
# it is last clause
print
(
"
Unknown heading
"
)
index
=
index
+
1
# Append last clause (usually History)
clause
.
to_id
=
index
-
1
clause
.
to_id
=
len
(
mdLines_changes
)
-
1
clauses
.
append
(
clause
)
if
changeInClause
:
changed_clauses
.
append
(
clause
)
...
...
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