koishi-plugin-github-webhook-pusher 0.0.9 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/parser.js +14 -1
  2. package/package.json +1 -1
package/lib/parser.js CHANGED
@@ -90,9 +90,22 @@ function parseReleaseEvent(payload) {
90
90
  * 需求 4.3, 4.6: 提取分支名、提交列表(最多5条)和推送者信息
91
91
  */
92
92
  function parsePushEvent(payload) {
93
- const { ref, commits, repository, sender, compare } = payload;
93
+ const { ref, commits, repository, sender, compare, created, deleted } = payload;
94
94
  // 提取分支名(去掉 refs/heads/ 前缀)
95
95
  const branch = ref?.replace('refs/heads/', '') || '';
96
+ if ((!commits || commits.length === 0) && (created || deleted)) {
97
+ const actionText = created ? '创建分支' : '删除分支';
98
+ const type = created ? 'create' : 'delete';
99
+ return {
100
+ type,
101
+ displayType: (0, types_1.getDisplayType)(type),
102
+ repo: repository.full_name,
103
+ actor: sender.login,
104
+ action: actionText,
105
+ ref: branch,
106
+ url: repository.html_url,
107
+ };
108
+ }
96
109
  // 解析提交列表
97
110
  const allCommits = (commits || []).map((commit) => ({
98
111
  sha: commit.id?.substring(0, 7) || '',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-github-webhook-pusher",
3
3
  "description": "GitHub Webhook 事件推送插件",
4
- "version": "0.0.9",
4
+ "version": "0.1.1",
5
5
  "contributors": [
6
6
  "ClozyA <aoxuan233@gmail.com>"
7
7
  ],