Skip to content

Commit

Permalink
feat(generate): adds support for inline comments in rule lines
Browse files Browse the repository at this point in the history
  • Loading branch information
sverweij committed Sep 2, 2023
1 parent 6da54a2 commit 67c2fa9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dist/generate-codeowners.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/generate-codeowners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/generate-codeowners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 67c2fa9

Please sign in to comment.