diff --git a/dist/generate-codeowners.js b/dist/generate-codeowners.js index 0070ac0..050b328 100644 --- a/dist/generate-codeowners.js +++ b/dist/generate-codeowners.js @@ -22,7 +22,10 @@ function generateLine(pCSTLine, pTeamMap) { const lUserNames = uniq(pCSTLine.users.flatMap((pUser) => expandTeamToUserNames(pUser, pTeamMap))) .sort(compareUserNames) .join(" "); - return pCSTLine.filesPattern + pCSTLine.spaces + lUserNames; + return (pCSTLine.filesPattern + + pCSTLine.spaces + + lUserNames + + (pCSTLine.inlineComment ? ` #${pCSTLine.inlineComment}` : "")); } return pCSTLine.raw; } diff --git a/src/generate-codeowners.test.ts b/src/generate-codeowners.test.ts index 5db4ef9..8b081f4 100644 --- a/src/generate-codeowners.test.ts +++ b/src/generate-codeowners.test.ts @@ -208,6 +208,19 @@ tools/ @team-tgif`; ); }); + it("re-adds any inline comment", () => { + const lFixture = "no-plan-b/ @team # this is a comment"; + const lTeamMapFixture = { + team: ["b.a.barackus", "face", "hannibal", "murdock"], + }; + const lExpected = + "no-plan-b/ @b.a.barackus @face @hannibal @murdock # this is a comment"; + equal( + generateCodeOwnersFromString(lFixture, lTeamMapFixture, ""), + lExpected, + ); + }); + it("writes the kitchensink", () => { const lTeamMap = readTeamMap( new URL("./__mocks__/virtual-teams.yml", import.meta.url).pathname, diff --git a/src/generate-codeowners.ts b/src/generate-codeowners.ts index 3b0ca02..5c3dd6e 100644 --- a/src/generate-codeowners.ts +++ b/src/generate-codeowners.ts @@ -43,7 +43,12 @@ function generateLine( ) .sort(compareUserNames) .join(" "); - return pCSTLine.filesPattern + pCSTLine.spaces + lUserNames; + return ( + pCSTLine.filesPattern + + pCSTLine.spaces + + lUserNames + + (pCSTLine.inlineComment ? ` #${pCSTLine.inlineComment}` : "") + ); } return pCSTLine.raw; }