mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -07:00
* fixed pamd single line issue
* added changelog fragment
* supported case for 0 lines, improved test
(cherry picked from commit a3a40f6de3
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
34f963e2f4
commit
acc77182bb
4 changed files with 72 additions and 4 deletions
|
@ -733,14 +733,19 @@ class PamdService(object):
|
|||
lines = []
|
||||
current_line = self._head
|
||||
|
||||
mark = "# Updated by Ansible - %s" % datetime.now().isoformat()
|
||||
while current_line is not None:
|
||||
lines.append(str(current_line))
|
||||
current_line = current_line.next
|
||||
|
||||
if lines[1].startswith("# Updated by Ansible"):
|
||||
lines.pop(1)
|
||||
|
||||
lines.insert(1, "# Updated by Ansible - " + datetime.now().isoformat())
|
||||
if len(lines) <= 1:
|
||||
lines.insert(0, "")
|
||||
lines.insert(1, mark)
|
||||
else:
|
||||
if lines[1].startswith("# Updated by Ansible"):
|
||||
lines[1] = mark
|
||||
else:
|
||||
lines.insert(1, mark)
|
||||
|
||||
return '\n'.join(lines) + '\n'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue