Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cfengine_cli/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def stringify_single_line_nodes(nodes: list[Node]) -> str:
result += " "
if previous and previous.type == "=>":
result += " "
if previous and previous.type == "{":
if previous and previous.type == "{" and node.type != "}":
result += " "
if previous and node.type == "}":
if previous and node.type == "}" and previous.type != "{":
result += " "
result += string
previous = node
Expand Down
4 changes: 4 additions & 0 deletions tests/format/002_basics.expected.cf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ body common control
inputs => { "/var/cfengine/inputs/some_file.cf" };
linux::
inputs => { "/var/cfengine/inputs/other_file.cf" };
ubuntu::
inputs => {};
}

promise agent example
Expand All @@ -30,6 +32,8 @@ bundle agent main
# Comment at atttribute level
string => "some_value";

"empty_list" slist => {};

classes:
# Comment before promise
"a" if => "b";
Expand Down
5 changes: 5 additions & 0 deletions tests/format/002_basics.input.cf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ body common control{
inputs => { "/var/cfengine/inputs/some_file.cf" };
linux::
inputs => { "/var/cfengine/inputs/other_file.cf" };
ubuntu::
inputs => {};
}

promise agent example{
Expand All @@ -26,6 +28,9 @@ baz::
if => "bar"
# Comment at atttribute level
string => "some_value";
"empty_list"
slist => {
};
classes:
# Comment before promise
"a" if => "b";
Expand Down
1 change: 1 addition & 0 deletions tests/format/010_stakeholder.expected.cf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bundle agent main
{
packages:
"platform-python-devel" -> {};
"platform-python-devel" -> { "cfbs shebang", "ENT-1234" };

"platform-python-devel" -> { "cfbs shebang", "ENT-1234" }
Expand Down
1 change: 1 addition & 0 deletions tests/format/010_stakeholder.input.cf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bundle agent main
{
packages:
"platform-python-devel" -> { };
"platform-python-devel" -> { "cfbs shebang", "ENT-1234" };
"platform-python-devel" -> { "cfbs shebang", "ENT-1234" }
comment => "foo";
Expand Down
Loading