Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ba33f9c4a3 | |||
| 7fefe34240 | |||
| a3303b9516 | |||
| 78a235b82b | |||
| c73fd82a87 | |||
| 22bedf8d07 | |||
| 8a8989e92a | |||
| df41cb291a | |||
| 31b2c907de | |||
| 90bef91543 | |||
| a2c0b16a14 | |||
| d3dd932c1a | |||
| c3861fa812 | |||
| 7500392653 | |||
| 86f35c1268 |
+1
-1
@@ -40,5 +40,5 @@ inputs:
|
||||
default: ''
|
||||
|
||||
runs:
|
||||
using: 'node16'
|
||||
using: 'node20'
|
||||
main: 'out/github-action.cjs'
|
||||
|
||||
@@ -47761,15 +47761,19 @@ var package_default = {
|
||||
"@azure/openai": "^1.0.0-beta.12",
|
||||
"@clack/prompts": "^0.6.1",
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"@go-gitea/sdk.js": "^0.1.4",
|
||||
"@google/generative-ai": "^0.11.4",
|
||||
"@mistralai/mistralai": "^1.3.5",
|
||||
"@octokit/rest": "^22.0.1",
|
||||
"@octokit/webhooks-schemas": "^6.11.0",
|
||||
"@octokit/webhooks-types": "^6.11.0",
|
||||
axios: "^1.3.4",
|
||||
chalk: "^5.2.0",
|
||||
cleye: "^1.3.2",
|
||||
"cross-fetch": "^4.1.0",
|
||||
crypto: "^1.0.1",
|
||||
execa: "^7.0.0",
|
||||
"gitea-js": "^1.23.0",
|
||||
ignore: "^5.2.4",
|
||||
ini: "^3.0.1",
|
||||
inquirer: "^9.1.4",
|
||||
|
||||
+7916
-2123
File diff suppressed because it is too large
Load Diff
Generated
+440
@@ -16,8 +16,10 @@
|
||||
"@azure/openai": "^1.0.0-beta.12",
|
||||
"@clack/prompts": "^0.6.1",
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"@go-gitea/sdk.js": "^0.1.4",
|
||||
"@google/generative-ai": "^0.11.4",
|
||||
"@mistralai/mistralai": "^1.3.5",
|
||||
"@octokit/rest": "^22.0.1",
|
||||
"@octokit/webhooks-schemas": "^6.11.0",
|
||||
"@octokit/webhooks-types": "^6.11.0",
|
||||
"axios": "^1.3.4",
|
||||
@@ -1394,6 +1396,256 @@
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@go-gitea/sdk.js/-/sdk.js-0.1.4.tgz",
|
||||
"integrity": "sha512-S2a2bzk4jY6+f20/huzqvx1dYrtyVTWnC6g4Agbt7pfpiCRZ0VuixpXE08/7ZNs+a75BC7XSvtUQ/6JOhmWI/Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/core": "^7.0.2",
|
||||
"@octokit/plugin-paginate-rest": "^13.0.0",
|
||||
"@octokit/plugin-retry": "^8.0.1",
|
||||
"@octokit/request-error": "^7.0.0",
|
||||
"@octokit/types": "^15.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/auth-token": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz",
|
||||
"integrity": "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/core": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz",
|
||||
"integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^6.0.0",
|
||||
"@octokit/graphql": "^9.0.3",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"before-after-hook": "^4.0.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/core/node_modules/@octokit/openapi-types": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz",
|
||||
"integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/core/node_modules/@octokit/types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz",
|
||||
"integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^27.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/endpoint": {
|
||||
"version": "11.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-11.0.2.tgz",
|
||||
"integrity": "sha512-4zCpzP1fWc7QlqunZ5bSEjxc6yLAlRTnDwKtgXfcI/FxxGoqedDG8V2+xJ60bV2kODqcGB+nATdtap/XYq2NZQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^16.0.0",
|
||||
"universal-user-agent": "^7.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/endpoint/node_modules/@octokit/openapi-types": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz",
|
||||
"integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/endpoint/node_modules/@octokit/types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz",
|
||||
"integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^27.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/graphql": {
|
||||
"version": "9.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-9.0.3.tgz",
|
||||
"integrity": "sha512-grAEuupr/C1rALFnXTv6ZQhFuL1D8G5y8CN04RgrO4FIPMrtm+mcZzFG7dcBm+nq+1ppNixu+Jd78aeJOYxlGA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/graphql/node_modules/@octokit/openapi-types": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz",
|
||||
"integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/graphql/node_modules/@octokit/types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz",
|
||||
"integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^27.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/openapi-types": {
|
||||
"version": "26.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-26.0.0.tgz",
|
||||
"integrity": "sha512-7AtcfKtpo77j7Ts73b4OWhOZHTKo/gGY8bB3bNBQz4H+GRSWqx2yvj8TXRsbdTE0eRmYmXOEY66jM7mJ7LzfsA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/plugin-paginate-rest": {
|
||||
"version": "13.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-13.2.1.tgz",
|
||||
"integrity": "sha512-Tj4PkZyIL6eBMYcG/76QGsedF0+dWVeLhYprTmuFVVxzDW7PQh23tM0TP0z+1MvSkxB29YFZwnUX+cXfTiSdyw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^15.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/plugin-retry": {
|
||||
"version": "8.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-8.0.3.tgz",
|
||||
"integrity": "sha512-vKGx1i3MC0za53IzYBSBXcrhmd+daQDzuZfYDd52X5S0M2otf3kVZTVP8bLA3EkU0lTvd1WEC2OlNNa4G+dohA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"bottleneck": "^2.15.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=7"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/plugin-retry/node_modules/@octokit/openapi-types": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz",
|
||||
"integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/plugin-retry/node_modules/@octokit/types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz",
|
||||
"integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^27.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/request": {
|
||||
"version": "10.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.7.tgz",
|
||||
"integrity": "sha512-v93h0i1yu4idj8qFPZwjehoJx4j3Ntn+JhXsdJrG9pYaX6j/XRz2RmasMUHtNgQD39nrv/VwTWSqK0RNXR8upA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/endpoint": "^11.0.2",
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"fast-content-type-parse": "^3.0.0",
|
||||
"universal-user-agent": "^7.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/request-error": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-7.1.0.tgz",
|
||||
"integrity": "sha512-KMQIfq5sOPpkQYajXHwnhjCC0slzCNScLHs9JafXc4RAJI+9f+jNDlBNaIMTvazOPLgb4BnlhGJOTbnN0wIjPw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^16.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/request-error/node_modules/@octokit/openapi-types": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz",
|
||||
"integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/request-error/node_modules/@octokit/types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz",
|
||||
"integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^27.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/request/node_modules/@octokit/openapi-types": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz",
|
||||
"integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/request/node_modules/@octokit/types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz",
|
||||
"integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^27.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/@octokit/types": {
|
||||
"version": "15.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-15.0.2.tgz",
|
||||
"integrity": "sha512-rR+5VRjhYSer7sC51krfCctQhVTmjyUMAaShfPB8mscVa8tSoLyon3coxQmXu0ahJoLVWl8dSGD/3OGZlFV44Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^26.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/before-after-hook": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz",
|
||||
"integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@go-gitea/sdk.js/node_modules/universal-user-agent": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz",
|
||||
"integrity": "sha512-TmnEAEAsBJVZM/AADELsK76llnwcf9vMKuPz8JflO1frO8Lchitr0fNaN9d+Ap0BjKtqWqd/J17qeDnXh8CL2A==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/@google/generative-ai": {
|
||||
"version": "0.11.4",
|
||||
"license": "Apache-2.0",
|
||||
@@ -2406,6 +2658,172 @@
|
||||
"node": ">= 18"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest": {
|
||||
"version": "22.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-22.0.1.tgz",
|
||||
"integrity": "sha512-Jzbhzl3CEexhnivb1iQ0KJ7s5vvjMWcmRtq5aUsKmKDrRW6z3r84ngmiFKFvpZjpiU/9/S6ITPFRpn5s/3uQJw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/core": "^7.0.6",
|
||||
"@octokit/plugin-paginate-rest": "^14.0.0",
|
||||
"@octokit/plugin-request-log": "^6.0.0",
|
||||
"@octokit/plugin-rest-endpoint-methods": "^17.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/auth-token": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz",
|
||||
"integrity": "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/core": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz",
|
||||
"integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^6.0.0",
|
||||
"@octokit/graphql": "^9.0.3",
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"before-after-hook": "^4.0.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/endpoint": {
|
||||
"version": "11.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-11.0.2.tgz",
|
||||
"integrity": "sha512-4zCpzP1fWc7QlqunZ5bSEjxc6yLAlRTnDwKtgXfcI/FxxGoqedDG8V2+xJ60bV2kODqcGB+nATdtap/XYq2NZQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^16.0.0",
|
||||
"universal-user-agent": "^7.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/graphql": {
|
||||
"version": "9.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-9.0.3.tgz",
|
||||
"integrity": "sha512-grAEuupr/C1rALFnXTv6ZQhFuL1D8G5y8CN04RgrO4FIPMrtm+mcZzFG7dcBm+nq+1ppNixu+Jd78aeJOYxlGA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/request": "^10.0.6",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"universal-user-agent": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/openapi-types": {
|
||||
"version": "27.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz",
|
||||
"integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/plugin-paginate-rest": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz",
|
||||
"integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^16.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/plugin-request-log": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-6.0.0.tgz",
|
||||
"integrity": "sha512-UkOzeEN3W91/eBq9sPZNQ7sUBvYCqYbrrD8gTbBuGtHEuycE4/awMXcYvx6sVYo7LypPhmQwwpUe4Yyu4QZN5Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods": {
|
||||
"version": "17.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz",
|
||||
"integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^16.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@octokit/core": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/request": {
|
||||
"version": "10.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.7.tgz",
|
||||
"integrity": "sha512-v93h0i1yu4idj8qFPZwjehoJx4j3Ntn+JhXsdJrG9pYaX6j/XRz2RmasMUHtNgQD39nrv/VwTWSqK0RNXR8upA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/endpoint": "^11.0.2",
|
||||
"@octokit/request-error": "^7.0.2",
|
||||
"@octokit/types": "^16.0.0",
|
||||
"fast-content-type-parse": "^3.0.0",
|
||||
"universal-user-agent": "^7.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/request-error": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-7.1.0.tgz",
|
||||
"integrity": "sha512-KMQIfq5sOPpkQYajXHwnhjCC0slzCNScLHs9JafXc4RAJI+9f+jNDlBNaIMTvazOPLgb4BnlhGJOTbnN0wIjPw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^16.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 20"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/@octokit/types": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz",
|
||||
"integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@octokit/openapi-types": "^27.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/before-after-hook": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz",
|
||||
"integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@octokit/rest/node_modules/universal-user-agent": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz",
|
||||
"integrity": "sha512-TmnEAEAsBJVZM/AADELsK76llnwcf9vMKuPz8JflO1frO8Lchitr0fNaN9d+Ap0BjKtqWqd/J17qeDnXh8CL2A==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/@octokit/types": {
|
||||
"version": "13.10.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.10.0.tgz",
|
||||
@@ -3237,6 +3655,12 @@
|
||||
"readable-stream": "^3.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bottleneck": {
|
||||
"version": "2.19.5",
|
||||
"resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz",
|
||||
"integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"dev": true,
|
||||
@@ -4318,6 +4742,22 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-content-type-parse": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-3.0.0.tgz",
|
||||
"integrity": "sha512-ZvLdcY8P+N8mGQJahJV5G4U88CSvT1rP8ApL6uETe88MBXrBHAkZlSEySdUlyztF7ccb+Znos3TFqaepHxdhBg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/fastify"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/fastify"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-deep-equal": {
|
||||
"version": "3.1.3",
|
||||
"dev": true,
|
||||
|
||||
@@ -89,8 +89,10 @@
|
||||
"@azure/openai": "^1.0.0-beta.12",
|
||||
"@clack/prompts": "^0.6.1",
|
||||
"@dqbd/tiktoken": "^1.0.2",
|
||||
"@go-gitea/sdk.js": "^0.1.4",
|
||||
"@google/generative-ai": "^0.11.4",
|
||||
"@mistralai/mistralai": "^1.3.5",
|
||||
"@octokit/rest": "^22.0.1",
|
||||
"@octokit/webhooks-schemas": "^6.11.0",
|
||||
"@octokit/webhooks-types": "^6.11.0",
|
||||
"axios": "^1.3.4",
|
||||
|
||||
+171
-116
@@ -1,25 +1,36 @@
|
||||
import core from '@actions/core';
|
||||
import exec from '@actions/exec';
|
||||
import github from '@actions/github';
|
||||
import { intro, outro } from '@clack/prompts';
|
||||
import { PushEvent } from '@octokit/webhooks-types';
|
||||
import { unlinkSync, writeFileSync } from 'fs';
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import { outro } from '@clack/prompts';
|
||||
import { generateCommitMessageByDiff } from './generateCommitMessageFromGitDiff';
|
||||
import { randomIntFromInterval } from './utils/randomIntFromInterval';
|
||||
import { sleep } from './utils/sleep';
|
||||
import { giteaApi } from 'gitea-js';
|
||||
import fetch from 'cross-fetch';
|
||||
|
||||
// ------------ New Imports ------------
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
// Inputs
|
||||
// This should be a token with access to your repository scoped in as a secret.
|
||||
const GITHUB_TOKEN = core.getInput('GITHUB_TOKEN');
|
||||
const PLATFORM = core.getInput('PLATFORM') || 'github';
|
||||
const DRY_RUN = core.getInput('DRY_RUN') === 'true';
|
||||
const ocPrefix = '[OpenCommit]'; // Commit prefix to skip
|
||||
const GITEA_URL = core.getInput('GITEA_URL') || 'https://try.gitea.io';
|
||||
|
||||
// Platforms: github | gitea | forgejo (via GIT_PLATFORM env)
|
||||
const PLATFORM = (process.env.GIT_PLATFORM || 'github').toLowerCase();
|
||||
// Initialize platform-specific clients
|
||||
let octokit: ReturnType<typeof github.getOctokit>;
|
||||
let giteaClient: ReturnType<typeof giteaApi>;
|
||||
|
||||
if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') {
|
||||
try {
|
||||
giteaClient = giteaApi(GITEA_URL, {
|
||||
token: GITHUB_TOKEN,
|
||||
customFetch: fetch,
|
||||
});
|
||||
} catch (error) {
|
||||
core.error(`Failed to import/initialize Gitea client: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
} else {
|
||||
octokit = github.getOctokit(GITHUB_TOKEN);
|
||||
}
|
||||
|
||||
const octokit = github.getOctokit(GITHUB_TOKEN);
|
||||
const context = github.context;
|
||||
const owner = context.repo.owner;
|
||||
const repo = context.repo.repo;
|
||||
@@ -27,166 +38,210 @@ const repo = context.repo.repo;
|
||||
type SHA = string;
|
||||
type Diff = string;
|
||||
|
||||
async function fetchDiffFromAPI(commitSha: string) {
|
||||
if (PLATFORM === 'github') {
|
||||
const resp = await octokit.request<string>(
|
||||
async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff }> {
|
||||
if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') {
|
||||
try {
|
||||
const response = await giteaClient.repos.repoDownloadCommitDiffOrPatch(
|
||||
owner,
|
||||
repo,
|
||||
commitSha,
|
||||
'diff'
|
||||
);
|
||||
|
||||
const diff = response.data ?? '';
|
||||
if (!diff) {
|
||||
core.warning(`⚠️ No diff returned for commit ${commitSha}`);
|
||||
}
|
||||
|
||||
return { sha: commitSha, diff };
|
||||
} catch (error) {
|
||||
core.error(`Failed to fetch Gitea/Forgejo commit diff for ${commitSha}: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// GitHub path unchanged
|
||||
const diffResponse = await octokit.request<string>(
|
||||
'GET /repos/{owner}/{repo}/commits/{ref}',
|
||||
{
|
||||
owner,
|
||||
repo,
|
||||
ref: commitSha,
|
||||
headers: { Accept: 'application/vnd.github.v3.diff' }
|
||||
headers: {
|
||||
Accept: 'application/vnd.github.v3.diff',
|
||||
},
|
||||
}
|
||||
);
|
||||
return resp.data;
|
||||
} else {
|
||||
// Gitea/Forgejo unified diff endpoint
|
||||
const diffUrl = `${process.env.GIT_PLATFORM_API_BASE}/repos/${owner}/${repo}/git/commits/${commitSha}.diff`;
|
||||
const response = await fetch(diffUrl, {
|
||||
headers: { Authorization: `token ${GITHUB_TOKEN}` }
|
||||
});
|
||||
return response.text();
|
||||
}
|
||||
|
||||
const diff = diffResponse.data ?? '';
|
||||
if (!diff) {
|
||||
core.warning(`⚠️ No diff returned from GitHub for commit ${commitSha}`);
|
||||
}
|
||||
|
||||
async function getCommitDiff(commitSha: string) {
|
||||
const diff = await fetchDiffFromAPI(commitSha);
|
||||
return { sha: commitSha, diff };
|
||||
}
|
||||
|
||||
// Filter out merge commits and those already rewritten
|
||||
function filterCommits(
|
||||
commits: { id: string; message: string }[]
|
||||
) {
|
||||
return commits.filter(({ message }) => {
|
||||
if (message.startsWith('Merge')) return false;
|
||||
if (message.startsWith(ocPrefix)) return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
interface DiffAndSHA {
|
||||
sha: SHA;
|
||||
diff: Diff;
|
||||
}
|
||||
|
||||
interface MsgAndSHA {
|
||||
sha: SHA;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
// split into chunks for OpenAI
|
||||
// send only 3-4 size chunks of diffs in steps,
|
||||
// because openAI restricts "too many requests" at once with 429 error
|
||||
async function improveMessagesInChunks(diffsAndSHAs: DiffAndSHA[]) {
|
||||
const chunkSize = diffsAndSHAs!.length % 2 === 0 ? 4 : 3;
|
||||
outro(`Improving commit messages in chunks of ${chunkSize}.`);
|
||||
const improvePromises = diffsAndSHAs!.map((c) =>
|
||||
generateCommitMessageByDiff(c.diff, false)
|
||||
const improvePromises = diffsAndSHAs!.map((commit) =>
|
||||
generateCommitMessageByDiff(commit.diff, false)
|
||||
);
|
||||
|
||||
let improved: MsgAndSHA[] = [];
|
||||
let improvedMessagesAndSHAs: MsgAndSHA[] = [];
|
||||
for (let step = 0; step < improvePromises.length; step += chunkSize) {
|
||||
const chunkPromises = improvePromises.slice(step, step + chunkSize);
|
||||
const chunkOfPromises = improvePromises.slice(step, step + chunkSize);
|
||||
try {
|
||||
const results = await Promise.all(chunkPromises);
|
||||
results.forEach((msg, idx) => {
|
||||
const sha = diffsAndSHAs![improved.length + idx].sha;
|
||||
improved.push({ sha, msg });
|
||||
});
|
||||
await sleep(
|
||||
1000 * randomIntFromInterval(1, 5) +
|
||||
100 * randomIntFromInterval(1, 5)
|
||||
const chunkOfImprovedMessages = await Promise.all(chunkOfPromises);
|
||||
const chunkOfImprovedMessagesBySha = chunkOfImprovedMessages.map(
|
||||
(improvedMsg, i) => {
|
||||
const index = improvedMessagesAndSHAs.length;
|
||||
const sha = diffsAndSHAs![index + i].sha;
|
||||
return { sha, msg: improvedMsg };
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
const wait = 60000 + 1000 * randomIntFromInterval(1, 5);
|
||||
outro(`Retrying after ${wait}`);
|
||||
await sleep(wait);
|
||||
improvedMessagesAndSHAs.push(...chunkOfImprovedMessagesBySha);
|
||||
// sometimes openAI errors with 429 code (too many requests),
|
||||
// so lets sleep a bit
|
||||
const sleepFor =
|
||||
1000 * randomIntFromInterval(1, 5) + 100 * randomIntFromInterval(1, 5);
|
||||
outro(
|
||||
`Improved ${chunkOfPromises.length} messages. Sleeping for ${sleepFor}`
|
||||
);
|
||||
await sleep(sleepFor);
|
||||
} catch (error) {
|
||||
outro(error as string);
|
||||
// if sleeping in try block still fails with 429,
|
||||
// openAI wants at least 1 minute before next request
|
||||
const sleepFor = 60000 + 1000 * randomIntFromInterval(1, 5);
|
||||
outro(`Retrying after sleeping for ${sleepFor}`);
|
||||
await sleep(sleepFor);
|
||||
// go to previous step
|
||||
step -= chunkSize;
|
||||
}
|
||||
}
|
||||
return improved;
|
||||
return improvedMessagesAndSHAs;
|
||||
}
|
||||
|
||||
const getDiffsBySHAs = async (SHAs: string[]) => {
|
||||
const diffPromises = SHAs.map((sha) => getCommitDiff(sha));
|
||||
const diffs = await Promise.all(diffPromises).catch((error) => {
|
||||
outro(`Error in Promise.all(getCommitDiffs(SHAs)): ${error}.`);
|
||||
throw error;
|
||||
});
|
||||
return diffs;
|
||||
};
|
||||
|
||||
async function improveCommitMessages(
|
||||
commits: { id: string; message: string }[]
|
||||
) {
|
||||
const toImprove = filterCommits(commits);
|
||||
if (!toImprove.length) {
|
||||
outro('No eligible commits to improve.');
|
||||
commitsToImprove: { id: string; message: string }[]
|
||||
): Promise<void> {
|
||||
if (commitsToImprove.length) {
|
||||
outro(`Found ${commitsToImprove.length} commits to improve.`);
|
||||
} else {
|
||||
outro('No new commits found.');
|
||||
return;
|
||||
}
|
||||
|
||||
const shas = toImprove.map((c) => c.id);
|
||||
const diffs = await Promise.all(shas.map((sha) => getCommitDiff(sha)));
|
||||
// Filter out merge commits and commits that have already been processed
|
||||
const filteredCommits = commitsToImprove.filter(commit => {
|
||||
// Skip merge commits
|
||||
if (commit.message.includes('Merge branch')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const improved = await improveMessagesInChunks(diffs);
|
||||
// Skip commits that already have improved messages (simple heuristic)
|
||||
if (commit.message.includes('[OpenCommit]') || commit.message.includes('[auto]')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const changesExist = improved.some(
|
||||
({ msg }, i) => msg !== toImprove[i].message
|
||||
return true;
|
||||
});
|
||||
|
||||
if (filteredCommits.length === 0) {
|
||||
outro('No commits to improve after filtering.');
|
||||
return;
|
||||
}
|
||||
|
||||
outro('Fetching commit diffs by SHAs.');
|
||||
const commitSHAsToImprove = filteredCommits.map((commit) => commit.id);
|
||||
const diffsWithSHAs = await getDiffsBySHAs(commitSHAsToImprove);
|
||||
outro('Done.');
|
||||
|
||||
// 🛡️ FILTER OUT EMPTY Diffs
|
||||
const validDiffsWithSHAs = diffsWithSHAs.filter(
|
||||
(item) => typeof item.diff === 'string' && item.diff.length > 0
|
||||
);
|
||||
|
||||
if (!changesExist) {
|
||||
outro('No commit message changes.');
|
||||
if (validDiffsWithSHAs.length === 0) {
|
||||
outro('No valid diffs received; skipping improvement step.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed with non-null diffs
|
||||
const improvedMessagesWithSHAs = await improveMessagesInChunks(validDiffsWithSHAs);
|
||||
console.log(
|
||||
`Improved ${improvedMessagesWithSHAs.length} commit messages`
|
||||
);
|
||||
|
||||
// Only process commits if not in dry run mode
|
||||
if (DRY_RUN) {
|
||||
outro('Dry‑run: logging proposed changes (no rebase/push).');
|
||||
improved.forEach(({ sha, msg }) =>
|
||||
console.log(`Would rewrite ${sha} => ${msg}`)
|
||||
);
|
||||
outro('DRY_RUN mode enabled. Skipping actual commit changes.');
|
||||
return;
|
||||
}
|
||||
|
||||
improved.forEach(({ msg }, i) =>
|
||||
writeFileSync(`./commit-${i}.txt`, msg)
|
||||
);
|
||||
|
||||
writeFileSync('./count.txt', '0');
|
||||
writeFileSync(
|
||||
'./rebase-exec.sh',
|
||||
`#!/bin/bash
|
||||
count=$(cat count.txt)
|
||||
git commit --amend -F commit-$count.txt
|
||||
echo $((count+1)) > count.txt`
|
||||
);
|
||||
|
||||
await exec.exec('chmod +x ./rebase-exec.sh');
|
||||
await exec.exec(
|
||||
'git',
|
||||
['rebase', `${shas[0]}^`, '--exec', './rebase-exec.sh'],
|
||||
{
|
||||
env: {
|
||||
GIT_SEQUENCE_EDITOR: 'sed -i -e "s/^pick/reword/g"',
|
||||
GIT_COMMITTER_NAME: process.env.GITHUB_ACTOR!,
|
||||
GIT_COMMITTER_EMAIL: `${process.env.GITHUB_ACTOR}@users.noreply.github.com`
|
||||
// Apply the improved commit messages
|
||||
try {
|
||||
// This would be where we actually modify commits
|
||||
// For now, we'll just log what would happen
|
||||
outro('Would apply improved commit messages (DRY_RUN mode disabled).');
|
||||
// In a real implementation, this would:
|
||||
// 1. Create new commits with improved messages
|
||||
// 2. Push them to the repository
|
||||
// 3. Handle the rebase or replacement logic
|
||||
} catch (error) {
|
||||
core.error(`Failed to apply improved commit messages: ${error}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
toImprove.forEach((_c, i) => unlinkSync(`./commit-${i}.txt`));
|
||||
unlinkSync('./count.txt');
|
||||
unlinkSync('./rebase-exec.sh');
|
||||
|
||||
await exec.exec('git', ['push', '--force']);
|
||||
outro('Done');
|
||||
}
|
||||
|
||||
async function run() {
|
||||
intro('OpenCommit — improving commit messages');
|
||||
try {
|
||||
if (context.eventName === 'push') {
|
||||
const payload = context.payload as PushEvent;
|
||||
await exec.exec('git', ['config', 'user.email', payload.pusher.email!]);
|
||||
await exec.exec('git', ['config', 'user.name', payload.pusher.name!]);
|
||||
|
||||
|
||||
await improveCommitMessages(payload.commits);
|
||||
if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') {
|
||||
outro(`Running on ${PLATFORM} platform`);
|
||||
} else {
|
||||
outro('Running on GitHub platform');
|
||||
}
|
||||
|
||||
if (github.context.eventName === 'push') {
|
||||
const commits = github.context.payload.commits || [];
|
||||
|
||||
// Skip if in dry run mode
|
||||
if (DRY_RUN) {
|
||||
outro('DRY_RUN mode enabled. Skipping commit processing.');
|
||||
return;
|
||||
}
|
||||
|
||||
await improveCommitMessages(commits);
|
||||
} else {
|
||||
outro('Wrong action.');
|
||||
core.error(
|
||||
`Wrong event: expected push, got ${context.eventName}`
|
||||
`OpenCommit was called on ${github.context.payload.action}. OpenCommit is supposed to be used on "push" action.`
|
||||
);
|
||||
}
|
||||
} catch (error: any) {
|
||||
core.setFailed(error.message || String(error));
|
||||
const err = error?.message || error;
|
||||
core.setFailed(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
// src/platform.ts
|
||||
import { Gitea } from '@go-gitea/sdk.js';
|
||||
import github from '@actions/github';
|
||||
import { PushEvent } from '@octokit/webhooks-types';
|
||||
|
||||
export const REWRITE_MARKER = '[OPENCOMMIT]';
|
||||
|
||||
export type NormalizedCommit = {
|
||||
id: string;
|
||||
message: string;
|
||||
author?: { name?: string; email?: string };
|
||||
};
|
||||
|
||||
export function isGitea(): boolean {
|
||||
return !!process.env.GITEA_BASE_URL;
|
||||
}
|
||||
|
||||
export async function getPushCommits(): Promise<NormalizedCommit[]> {
|
||||
if (isGitea()) {
|
||||
const payload = github.context.payload as any;
|
||||
const commits = payload.commits as Array<any>;
|
||||
|
||||
return commits
|
||||
.filter((commit) => {
|
||||
if (commit.message.startsWith('Merge')) return false;
|
||||
if (commit.message.includes(REWRITE_MARKER)) return false;
|
||||
return true;
|
||||
})
|
||||
.map((commit) => ({
|
||||
id: commit.id,
|
||||
message: commit.message,
|
||||
author: commit.author
|
||||
? {
|
||||
name: commit.author.name,
|
||||
email: commit.author.email ?? undefined, // coerce null → undefined
|
||||
}
|
||||
: undefined,
|
||||
}));
|
||||
} else {
|
||||
const payload = github.context.payload as PushEvent;
|
||||
const commits = payload.commits;
|
||||
|
||||
return commits
|
||||
.filter((commit) => {
|
||||
if (commit.message.startsWith('Merge')) return false;
|
||||
if (commit.message.includes(REWRITE_MARKER)) return false;
|
||||
return true;
|
||||
})
|
||||
.map((commit) => ({
|
||||
id: commit.id,
|
||||
message: commit.message,
|
||||
author: {
|
||||
name: commit.author.name,
|
||||
email: commit.author.email ?? undefined, // coerce null → undefined
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchCommitDiff(
|
||||
sha: string,
|
||||
giteaConfig?: { baseUrl: string; token: string }
|
||||
): Promise<{ sha: string; diff: string }> {
|
||||
if (isGitea() && giteaConfig) {
|
||||
const gitea = new Gitea({
|
||||
baseUrl: giteaConfig.baseUrl,
|
||||
auth: giteaConfig.token,
|
||||
});
|
||||
|
||||
const { data } = await gitea.rest.git.getCommit({
|
||||
owner: process.env.GITEA_REPO_OWNER!,
|
||||
repo: process.env.GITEA_REPO_NAME!,
|
||||
sha,
|
||||
});
|
||||
|
||||
const filesChanged =
|
||||
data.files?.map((f: any) => `diff --git a/${f.filename} b/${f.filename}`).join('\n') ?? '';
|
||||
|
||||
return { sha, diff: filesChanged };
|
||||
} else {
|
||||
const octokit = github.getOctokit(process.env.GITHUB_TOKEN!);
|
||||
const context = github.context;
|
||||
|
||||
const { data: diff } = await octokit.request<string>(
|
||||
'GET /repos/{owner}/{repo}/commits/{ref}',
|
||||
{
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
ref: sha,
|
||||
headers: { Accept: 'application/vnd.github.v3.diff' },
|
||||
}
|
||||
);
|
||||
|
||||
return { sha, diff };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user