Skip to content

Commit 7028164

Browse files
authored
fix: undefined URLs in PullRequestEvent activity feed and add fallback emoji icons
1 parent 76c2edb commit 7028164

File tree

3 files changed

+51
-15
lines changed

3 files changed

+51
-15
lines changed

dist/index.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19896,7 +19896,11 @@ const toUrlFormat = (item) => {
1989619896
return `[#${item.payload.issue.number}](${item.payload.issue.html_url})`;
1989719897
}
1989819898
if (Object.hasOwnProperty.call(item.payload, "pull_request")) {
19899-
return `[#${item.payload.pull_request.number}](${item.payload.pull_request.html_url})`;
19899+
// GitHub Events API doesn't include html_url in pull_request object
19900+
// We need to construct it from repo name and PR number
19901+
const prNumber = item.payload.pull_request.number;
19902+
const repoName = item.repo.name;
19903+
return `[#${prNumber}](https://github.com/${repoName}/pull/${prNumber})`;
1990019904
}
1990119905

1990219906
if (Object.hasOwnProperty.call(item.payload, "release")) {
@@ -19995,7 +19999,7 @@ const serializers = {
1999519999
)}`;
1999620000
},
1999720001
IssuesEvent: (item) => {
19998-
let emoji = "";
20002+
let emoji = "ℹ️";
1999920003

2000020004
switch (item.payload.action) {
2000120005
case "opened":
@@ -20014,11 +20018,25 @@ const serializers = {
2001420018
)} in ${toUrlFormat(item.repo.name)}`;
2001520019
},
2001620020
PullRequestEvent: (item) => {
20017-
const emoji = item.payload.action === "opened" ? "💪" : "❌";
20018-
const line = item.payload.pull_request.merged
20019-
? "🎉 Merged"
20020-
: `${emoji} ${capitalize(item.payload.action)}`;
20021-
return `${line} PR ${toUrlFormat(item)} in ${toUrlFormat(item.repo.name)}`;
20021+
let emoji = "ℹ️";
20022+
let actionText = capitalize(item.payload.action);
20023+
20024+
switch (item.payload.action) {
20025+
case "opened":
20026+
emoji = "💪";
20027+
actionText = "Opened";
20028+
break;
20029+
case "closed":
20030+
emoji = "❌";
20031+
actionText = "Closed";
20032+
break;
20033+
case "merged":
20034+
emoji = "🎉";
20035+
actionText = "Merged";
20036+
break;
20037+
}
20038+
20039+
return `${emoji} ${actionText} PR ${toUrlFormat(item)} in ${toUrlFormat(item.repo.name)}`;
2002220040
},
2002320041
ReleaseEvent: (item) => {
2002420042
return `🚀 ${capitalize(item.payload.action)} release ${toUrlFormat(

index.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ const toUrlFormat = (item) => {
3838
return `[#${item.payload.issue.number}](${item.payload.issue.html_url})`;
3939
}
4040
if (Object.hasOwnProperty.call(item.payload, "pull_request")) {
41-
return `[#${item.payload.pull_request.number}](${item.payload.pull_request.html_url})`;
41+
// GitHub Events API doesn't include html_url in pull_request object
42+
// We need to construct it from repo name and PR number
43+
const prNumber = item.payload.pull_request.number;
44+
const repoName = item.repo.name;
45+
return `[#${prNumber}](https://github.com/${repoName}/pull/${prNumber})`;
4246
}
4347

4448
if (Object.hasOwnProperty.call(item.payload, "release")) {
@@ -137,7 +141,7 @@ const serializers = {
137141
)}`;
138142
},
139143
IssuesEvent: (item) => {
140-
let emoji = "";
144+
let emoji = "ℹ️";
141145

142146
switch (item.payload.action) {
143147
case "opened":
@@ -156,11 +160,25 @@ const serializers = {
156160
)} in ${toUrlFormat(item.repo.name)}`;
157161
},
158162
PullRequestEvent: (item) => {
159-
const emoji = item.payload.action === "opened" ? "💪" : "❌";
160-
const line = item.payload.pull_request.merged
161-
? "🎉 Merged"
162-
: `${emoji} ${capitalize(item.payload.action)}`;
163-
return `${line} PR ${toUrlFormat(item)} in ${toUrlFormat(item.repo.name)}`;
163+
let emoji = "ℹ️";
164+
let actionText = capitalize(item.payload.action);
165+
166+
switch (item.payload.action) {
167+
case "opened":
168+
emoji = "💪";
169+
actionText = "Opened";
170+
break;
171+
case "closed":
172+
emoji = "❌";
173+
actionText = "Closed";
174+
break;
175+
case "merged":
176+
emoji = "🎉";
177+
actionText = "Merged";
178+
break;
179+
}
180+
181+
return `${emoji} ${actionText} PR ${toUrlFormat(item)} in ${toUrlFormat(item.repo.name)}`;
164182
},
165183
ReleaseEvent: (item) => {
166184
return `🚀 ${capitalize(item.payload.action)} release ${toUrlFormat(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-activity-readme",
3-
"version": "0.4.5",
3+
"version": "0.4.6",
44
"description": "Updates README with the recent GitHub activity of a user",
55
"main": "index.js",
66
"keywords": [],

0 commit comments

Comments
 (0)