Skip to content

Commit

Permalink
Feature: Split PR & issues into separate events (#272)
Browse files Browse the repository at this point in the history
* feat: split pr events

* docs: update split pr events

* docs: update readme w/ new pr events

* docs: fix vscode auto toc update

* feat: split issues into separate open/close events

* fix: old serializer eventname

* fix: refactor gh api event types

* docs: update readme

* fix: update eventlist

---------

Co-authored-by: Puneet Gopinath <baalkrshna@gmail.com>
  • Loading branch information
A2-NieR and PuneetGopinath authored May 2, 2023
1 parent 333459a commit fba5248
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Events we support:
- ForkEvent - You forked a repo
- GollumEvent - Wiki was updated in a repo
- IssueCommentEvent - You commented on a issue
- IssuesEvent - You opened a issue
- IssuesEvent - You opened or closed an issue
- MemberEvent - You joined a org/repo as a member
- PullRequestEvent - You opened a pr.
- PullRequestEvent - You opened, merged or closed a pr.
- PullRequestReviewCommentEvent - You commented on a pr review
- PullRequestReviewEvent - You reviewed a pr
- ReleaseEvent - You released a new version
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,24 @@ The setting can be used in two ways:
##### Supported Events
The following list of events is supported for the [`disabled_events`](#disabled_events) and [`whitelisted_events`](#whitelisted_events) setting.

| Type: | Disabled Actions: |
| ------------- | ------------------------------------------------- |
| `comments` | Commenting on Issues |
| `create_repo` | Creating a new Repository |
| `fork` | Forking a Repository |
| `issues` | Opening or closing Issues |
| `member` | Getting added as a Collaborator/Member |
| `pr` | Opening, closing or Merging a Pull request |
| `push` | All commits performed |
| `release` | Publishing a new Release |
| `review` | Approving or requesting Changes in a Pull request |
| `star` | Starring a Repository |
| `wiki` | Creating a new Wiki page |
| Type: | Disabled Actions: |
| -------------- | ------------------------------------------------- |
| `comments` | Commenting on Issues |
| `create_repo` | Creating a new Repository |
| `fork` | Forking a Repository |
| `issues` | All Issues actions |
| `issues_open` | Opening Issues |
| `issues_close` | Closing Issues |
| `member` | Getting added as a Collaborator/Member |
| `pr` | All Pull request actions |
| `pr_open` | Opening a Pull request |
| `pr_merge` | Merging a Pull request |
| `pr_close` | Closing a Pull request |
| `push` | All commits performed |
| `release` | Publishing a new Release |
| `review` | Approving or requesting Changes in a Pull request |
| `star` | Starring a Repository |
| `wiki` | Creating a new Wiki page |

#### `commit_name`
> **Default:** `readme-bot`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "activity-readme",
"version": "2.4.1",
"version": "2.5.0",
"description": "Updates README with the recent GitHub activity of a user. This project is a fork of https://github.com/jamesgeorge007/github-activity-readme",
"main": "src/index.js",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const defaultVals = {
text: "Last Updated: {DATE}",
format: "dddd, mmmm dS, yyyy, h:MM:ss TT",
},
ignored_repos:[],
ignored_repos: [],
comments: "💬 Commented on {ID} in {REPO}",
push: "⬆️ Pushed {AMOUNT} commit(s) to {REPO}",
issue_opened: "❗️ Opened issue {ID} in {REPO}",
Expand Down
7 changes: 6 additions & 1 deletion src/eventList.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
/**
* Copyright (c) 2021 The Readme-Workflows organisation and Contributors
* Copyright (c) 2023 The Readme-Workflows organisation and Contributors
*/
module.exports = [
"comments",
"push",
"create_repo",
"fork",
"issues",
"issues_open",
"issues_close",
"member",
"pr",
"pr_open",
"pr_merge",
"pr_close",
"release",
"review",
"star",
Expand Down
41 changes: 40 additions & 1 deletion src/functions/filterContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const serializers = require("../serializers");
const { max_lines, ignored_repos } = require("../config");
const { max_lines, ignored_repos, disabled_events } = require("../config");
const { amountReplace } = require("./amountReplacer");

const filterContent = (eventData) => {
Expand All @@ -16,6 +16,45 @@ const filterContent = (eventData) => {
(event) => !ignored_repos.includes(event.repo.name)
);
}

if (disabled_events instanceof Array && disabled_events.length != 0) {
eventData = eventData.filter((event) => {
if (
disabled_events.includes("issues_open") &&
event.payload.action === "opened" &&
event.type === "IssuesEvent"
) {
return false;
} else if (
disabled_events.includes("issues_close") &&
event.payload.action === "closed" &&
event.type === "IssuesEvent"
) {
return false;
} else if (
disabled_events.includes("pr_open") &&
event.payload.action === "opened" &&
event.type === "PullRequestEvent"
) {
return false;
} else if (
disabled_events.includes("pr_merge") &&
event.payload.pull_request.merged &&
event.type === "PullRequestEvent"
) {
return false;
} else if (
disabled_events.includes("pr_close") &&
event.payload.action === "closed" &&
event.type === "PullRequestEvent"
) {
return false;
} else {
return true;
}
});
}

for (let i = 0; i < eventData.length; i++) {
let event_string = serializers[eventData[i].type](eventData[i]);

Expand Down

0 comments on commit fba5248

Please sign in to comment.