Skip to content

Commit

Permalink
feat: rename function to descriptionToCoAuthors
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Aug 10, 2024
1 parent 87fac4b commit 0787421
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">Description to Co Authors</h1>

<p align="center">Parses co-authors from Git/GitHub-style commit messages. ✍️</p>
<p align="center">Parses co-authors from Git/GitHub-style commit messages and issue bodies. ✍️</p>

<p align="center">
<!-- prettier-ignore-start -->
Expand All @@ -22,14 +22,14 @@
npm i description-to-co-authors
```

Pass any variant of Git/GitHub-style commit message string to this package's exported `commitToCoAuthors`.
Pass any variant of Git/GitHub-style commit message or issue body string to this package's exported `descriptionToCoAuthors`.
It will collect data from each case-insensitive `co-authored-by:` match.
Data may include `email`, `name`, and/or `username`:

```ts
import { commitToCoAuthors } from "description-to-co-authors";
import { descriptionToCoAuthors } from "description-to-co-authors";

commitToCoAuthors(`
descriptionToCoAuthors(`
co-authored-by: @DirectUsername
Co-authored-by: Josh Goldberg <github@joshuakgoldberg.com>
`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "description-to-co-authors",
"version": "0.2.0",
"description": "Parses co-authors from Git/GitHub-style commit messages. ✍️",
"description": "Parses co-authors from Git/GitHub-style commit messages and issue bodies. ✍️",
"repository": {
"type": "git",
"url": "https://github.com/JoshuaKGoldberg/description-to-co-authors"
Expand Down
6 changes: 3 additions & 3 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, expect, it } from "vitest";

import { commitToCoAuthors } from "./index.js";
import { descriptionToCoAuthors } from "./index.js";

describe("commitToCoAuthors", () => {
describe("descriptionToCoAuthors", () => {
it.each([
["", []],
["unrelated", []],
Expand Down Expand Up @@ -35,6 +35,6 @@ describe("commitToCoAuthors", () => {
[{ email: "abc@def.ghi", name: "Three Full Names" }],
],
])("%s", (input, expected) => {
expect(commitToCoAuthors(input)).toEqual(expected);
expect(descriptionToCoAuthors(input)).toEqual(expected);
});
});
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export interface CoAuthor {
username?: string;
}

export function commitToCoAuthors(commit: string) {
export function descriptionToCoAuthors(description: string) {
const coAuthors: CoAuthor[] = [];

for (const match of commit.match(/co-authored-by:.+/gi) ?? []) {
for (const match of description.match(/co-authored-by:.+/gi) ?? []) {
const split = match.trim().split(/\s+/);
if (split.length < 2) {
continue;
Expand Down

0 comments on commit 0787421

Please sign in to comment.