Skip to content

Commit c6dde21

Browse files
committed
2022.08.08:
* fixed: bash/github/init-yq-workflow.sh: `yq_restore_edited_uniform_diff` inaccurate blank lines position
1 parent 9815f07 commit c6dde21

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

bash/github/init-yq-workflow.sh

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,9 @@ function yq_restore_edited_uniform_diff() # NOTE: Experimental
753753
local DiffChunkAddLineOffset
754754
local DiffChunkNumAddLines
755755
local DiffChunkOffsetShift
756+
756757
local AccumDiffChunkOffsetShift
758+
757759
local DiffRemoveChunkLine
758760
local DiffRemoveChunkLineKeyText
759761
local DiffRemoveChunkLineFiltered
@@ -762,13 +764,16 @@ function yq_restore_edited_uniform_diff() # NOTE: Experimental
762764
local DiffRemoveChunkLines
763765
local DiffRemoveChunkLinesLen
764766
local DiffRemoveChunkLinesIndex
767+
765768
local DiffAddChunkLine
766769
local DiffAddChunkLineKeyText
767770
local DiffAddChunkLineFiltered
768771
local DiffAddChunkLineFilteredLen
769772
local DiffAddChunkLines
770773
local DiffAddChunkLinesLen
771774
local DiffAddChunkLinesIndex
775+
local DiffAddChunkLinesToRemove
776+
772777
local MergedDiffChunkLineLen
773778
local MergeDiffAddChunkLineNextIndex
774779
local IsDiffAddChunkLineProcessed
@@ -795,6 +800,8 @@ function yq_restore_edited_uniform_diff() # NOTE: Experimental
795800
DiffRemoveChunkLinesLen="${#DiffRemoveChunkLines[@]}"
796801
DiffAddChunkLinesLen="${#DiffAddChunkLines[@]}"
797802

803+
DiffAddChunkLinesToRemove=()
804+
798805
MergeDiffAddChunkLineNextIndex=0
799806

800807
if (( DiffRemoveChunkLinesLen )); then
@@ -846,6 +853,9 @@ function yq_restore_edited_uniform_diff() # NOTE: Experimental
846853

847854
(( MergeDiffAddChunkLineNextIndex = DiffAddChunkLinesIndex + 1 ))
848855

856+
# unregister to remove
857+
unset DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex]
858+
849859
IsDiffAddChunkLineProcessed=1
850860

851861
break
@@ -868,22 +878,22 @@ function yq_restore_edited_uniform_diff() # NOTE: Experimental
868878

869879
(( MergeDiffAddChunkLineNextIndex = DiffAddChunkLinesIndex + 1 ))
870880

881+
# unregister to remove
882+
unset DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex]
883+
871884
IsDiffAddChunkLineProcessed=1
872885

873886
break
874887
elif [[ -n "$DiffAddChunkLineKeyText" ]]; then
875-
# yaml key is found, remove the line
876-
unset DiffAddChunkLines[DiffAddChunkLinesIndex]
877-
878-
(( DiffChunkNumAddLines-- ))
879-
(( DiffChunkOffsetShift-- ))
888+
# yaml key is found, register to remove the line if would not processed at all
889+
(( DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex] = 1 ))
880890
fi
881891
fi
882892
fi
883893
done
884894

885895
if (( ! IsDiffAddChunkLineProcessed )); then
886-
# shift
896+
# shift with not set values
887897
(( DiffAddChunkLinesLen++ ))
888898

889899
for (( DiffAddChunkLinesIndex = DiffAddChunkLinesLen; MergeDiffAddChunkLineNextIndex < DiffAddChunkLinesIndex; DiffAddChunkLinesIndex-- )); do
@@ -892,6 +902,12 @@ function yq_restore_edited_uniform_diff() # NOTE: Experimental
892902
else
893903
unset DiffAddChunkLines[DiffAddChunkLinesIndex]
894904
fi
905+
906+
if [[ -n "${DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex - 1]+x}" ]]; then
907+
DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex]="${DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex - 1]}"
908+
else
909+
unset DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex]
910+
fi
895911
done
896912

897913
DiffAddChunkLines[MergeDiffAddChunkLineNextIndex++]="${DiffRemoveChunkLines[DiffRemoveChunkLinesIndex]}" # insert
@@ -928,6 +944,16 @@ function yq_restore_edited_uniform_diff() # NOTE: Experimental
928944
fi
929945
fi
930946

947+
# remove chunk addition lines registered to remove
948+
for (( DiffAddChunkLinesIndex=0; DiffAddChunkLinesIndex < DiffAddChunkLinesLen; DiffAddChunkLinesIndex++ )); do
949+
if (( DiffAddChunkLinesToRemove[DiffAddChunkLinesIndex] )); then
950+
unset DiffAddChunkLines[DiffAddChunkLinesIndex]
951+
952+
(( DiffChunkNumAddLines-- ))
953+
(( DiffChunkOffsetShift-- ))
954+
fi
955+
done
956+
931957
(( DiffChunkAddLineOffset += AccumDiffChunkOffsetShift ))
932958

933959
diff_make_uniform_chunk_header "$DiffChunkRemoveLineOffset" "$DiffChunkNumRemoveLines" "$DiffChunkAddLineOffset" "$DiffChunkNumAddLines" "$DiffChunkOffsetShift"

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2022.08.08:
2+
* fixed: bash/github/init-yq-workflow.sh: `yq_restore_edited_uniform_diff` inaccurate blank lines position
3+
14
2022.08.07:
25
* fixed: bash/github/init-*-workflow.sh: minor fixup
36
* new: bash/github: added `init-diff-workflow.sh` to support `diff` command workflow

userlog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
33
> :warning: to find all changes use [changelog.txt](https://github.com/andry81-devops/gh-workflow/blob/master/changelog.txt) file in a directory
44
5+
## 2022.08.08:
6+
* fixed: bash/github/init-yq-workflow.sh: `yq_restore_edited_uniform_diff` inaccurate blank lines position
7+
8+
## 2022.08.07:
9+
* new: bash/github: added `init-diff-workflow.sh` to support `diff` command workflow
10+
* new: bash/github/init-yq-workflow.sh: `yq_restore_edited_uniform_diff` function to restore yaml comments and blank lines
11+
* changed: bash/cache/accum-content.sh: use `yq_restore_edited_uniform_diff` function by default
12+
513
## 2022.05.31:
614
* new: bash/github/accum-stats.sh: added `STATS_REMOVED_DATES` return variable, print last removed dates additionally to the last changed dates
715
* new: bash/github/accum-stats.sh: `ENABLE_COMMIT_MESSAGE_DATE_TIME_WITH_LAST_CHANGED_DATE_OFFSET` environment variable to insert datetime suffix as offset to the last changed date in format `-DDT` to note the closest changed date

0 commit comments

Comments
 (0)