Skip to content

Commit 1e07a2c

Browse files
Merge f1b2c52 into 3a6e13d
2 parents 3a6e13d + f1b2c52 commit 1e07a2c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.snippets/25.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Process snippet only once
2+
<!--
3+
type: bugfix
4+
scope: all
5+
affected: all
6+
-->
7+
8+
A snippet is now only added once to the changelog, even if it has been touched or modified again at a later point in the commit history timeline.

snippets2changelog/collector.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def snippets(self) -> Iterator[Tuple[Commit, Path]]:
101101
# self._logger.debug(f"collected_snippets: {collected_snippets}, looking for {self.snippets_folder}")
102102
# collected_snippets: [PosixPath('.snippets/3.md')], looking for .snippets
103103

104+
# remember which snippets have already been visited to avoid processing
105+
# it twice in case it has been touched or modified at a later point
106+
processed_snippets = []
107+
104108
# use reversed to have oldest commit as first element
105109
for idx, commit in reversed(list(enumerate(self.commits()))):
106110
for file in commit.stats.files.keys():
@@ -113,7 +117,8 @@ def snippets(self) -> Iterator[Tuple[Commit, Path]]:
113117
self._logger.warning(f"file {self.snippets_folder / file} is a match")
114118
yield (commit, self.snippets_folder / file)
115119
"""
116-
if Path(file) in collected_snippets:
120+
if Path(file) in collected_snippets and Path(file) not in processed_snippets:
117121
# self._logger.debug(f"file {file} is a match")
118122
# file .snippets/3.md is a match
123+
processed_snippets.append(Path(file))
119124
yield (commit, Path(file))

0 commit comments

Comments
 (0)