@@ -1046,6 +1046,27 @@ def commit(args):
10461046 assert mo .group ("begin" ) == years [:4 ] + "-"
10471047 assert mo .group ("holder" ) == "Gentoo Authors"
10481048
1049+ # keep the rest of the ebuild, only the spacing after EAPI= varies
1050+ with open (ebuild_path ) as f :
1051+ lines = f .read ().splitlines ()
1052+ eapi_lineno = next (i for i , line in enumerate (lines ) if line .startswith ("EAPI=" ))
1053+ head , rest = lines [: eapi_lineno + 1 ], [x for x in lines [eapi_lineno + 1 :] if x ]
1054+
1055+ for original , expected in (
1056+ (["# comment" ], ["" , "# comment" ]),
1057+ (["" , "# comment" ], ["" , "# comment" ]),
1058+ # a line which merely looks empty isn't one
1059+ ([" " , "# comment" ], ["" , " " , "# comment" ]),
1060+ ):
1061+ # munge the lines after the EAPI assignment
1062+ with open (ebuild_path , "w" ) as f :
1063+ f .write ("\n " .join (head + original + rest ) + "\n " )
1064+ commit (["-n" , "-u" , "-m" , "mangling" ])
1065+ # verify the blank line after EAPI= is there
1066+ with open (ebuild_path ) as f :
1067+ mangled = f .read ().splitlines ()
1068+ assert mangled [eapi_lineno + 1 : eapi_lineno + 1 + len (expected )] == expected
1069+
10491070 for original , expected in (
10501071 ('"arm64 amd64 x86"' , "amd64 arm64 x86" ),
10511072 ('"arm64 amd64 ~x86"' , "amd64 arm64 ~x86" ),
0 commit comments