Skip to content
Snippets Groups Projects
Commit a92f0681 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Fix to include added/removed lines as change

parent 10470d17
No related branches found
No related tags found
No related merge requests found
Pipeline #202 passed
...@@ -157,6 +157,8 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st ...@@ -157,6 +157,8 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
lines_removed = 0 lines_removed = 0
for change in patched_file: for change in patched_file:
change_start_line, change_end_line, change_lines_added, change_lines_removed = changeDetails(change) change_start_line, change_end_line, change_lines_added, change_lines_removed = changeDetails(change)
logging.debug(f"Change starting at line {change_start_line} and ending at line {change_end_line}")
logging.debug(f"Change containing {change_lines_added} added lines and {change_lines_removed} lines removed")
lines_added = lines_added + change_lines_added lines_added = lines_added + change_lines_added
lines_removed = lines_removed + change_lines_removed lines_removed = lines_removed + change_lines_removed
# Check the previous changed_clause # Check the previous changed_clause
...@@ -172,9 +174,11 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st ...@@ -172,9 +174,11 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
generateMDforChange(progress, mdLines, changed_clause, change, outDirectory, False) generateMDforChange(progress, mdLines, changed_clause, change, outDirectory, False)
break break
i = i + 1 i = i + 1
logging.info(f"Total number of lines added is {lines_added}")
logging.info(f"Total number of lines removed is {lines_removed}")
for clause in changed_clauses: for clause in changed_clauses:
logging.debug(f"Clause {clause.clause_nr} contains modifications") logging.info(f"Clause {clause.clause_nr} contains modifications")
return changed_clauses return changed_clauses
...@@ -185,7 +189,7 @@ def changeDetails(change) -> (int, int, int, int): ...@@ -185,7 +189,7 @@ def changeDetails(change) -> (int, int, int, int):
change_start_line = change.target_start change_start_line = change.target_start
change_end_line = change_start_line change_end_line = change_start_line
for line in change: for line in change:
print(vars(line)) #print(vars(line))
if line.is_added or line.is_removed: if line.is_added or line.is_removed:
#if change_start_line == change.target_start: #if change_start_line == change.target_start:
# change_start_line = change.target_start + i # change_start_line = change.target_start + i
...@@ -233,7 +237,8 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st ...@@ -233,7 +237,8 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
j = change.target_start - changed_clause.from_id # index gap j = change.target_start - changed_clause.from_id # index gap
for line in change: for line in change:
if (not (line.value.strip() == '') and (line.is_added)): #if (not (line.value.strip() == '') and (line.is_added)):
if line.is_added:
if line.value.strip().startswith("|"): # It is a table if line.value.strip().startswith("|"): # It is a table
tableElements = line.value.strip().split("|") tableElements = line.value.strip().split("|")
modifiedElements:list[str] = [] modifiedElements:list[str] = []
...@@ -251,7 +256,8 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st ...@@ -251,7 +256,8 @@ https://forge.etsi.org/rep/cdm/pipeline-scripts/-/blob/main/common/Dockerfile.st
#clauseMDlines.insert(j, "<mark>" + line.value.strip("\n") + "</mark>\n\n") #clauseMDlines.insert(j, "<mark>" + line.value.strip("\n") + "</mark>\n\n")
if (j + 1) <= len(clauseMDlines): if (j + 1) <= len(clauseMDlines):
clauseMDlines.pop(j+1) clauseMDlines.pop(j+1)
elif (not (line.value.strip() == '') and (line.is_removed)): #elif (not (line.value.strip() == '') and (line.is_removed)):
elif line.is_removed:
if line.value.strip().startswith("|"): # It is a table if line.value.strip().startswith("|"): # It is a table
tableElements = line.value.strip().split("|") tableElements = line.value.strip().split("|")
modifiedElements: list[str] = [] modifiedElements: list[str] = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment