Refactor using gitea-js.
Testing / prettier (push) Failing after 2m23s
Testing / e2e-test (20.x) (push) Failing after 2m45s
Testing / unit-test (20.x) (push) Failing after 3m59s

This commit is contained in:
2026-01-04 14:10:58 -05:00
parent 78a235b82b
commit a3303b9516
3 changed files with 7923 additions and 4502 deletions
+2
View File
@@ -47770,8 +47770,10 @@ var package_default = {
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",
+7908 -4490
View File
File diff suppressed because it is too large Load Diff
+13 -12
View File
@@ -4,6 +4,8 @@ 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';
// This should be a token with access to your repository scoped in as a secret.
const GITHUB_TOKEN = core.getInput('GITHUB_TOKEN');
@@ -13,18 +15,16 @@ const GITEA_URL = core.getInput('GITEA_URL') || 'https://try.gitea.io';
// Initialize platform-specific clients
let octokit: ReturnType<typeof github.getOctokit>;
let giteaClient: any; // We'll initialize this properly below
let giteaClient: ReturnType<typeof giteaApi>;
if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') {
// Dynamically import the Gitea client
try {
const gitea = require('@go-gitea/sdk.js').ApiClient;
giteaClient = new gitea({
baseUrl: GITEA_URL,
auth: GITHUB_TOKEN,
giteaClient = giteaApi(GITEA_URL, {
token: GITHUB_TOKEN,
customFetch: fetch,
});
} catch (error) {
core.error(`Failed to import Gitea client: ${error}`);
core.error(`Failed to import/initialize Gitea client: ${error}`);
throw error;
}
} else {
@@ -41,16 +41,16 @@ type Diff = string;
async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff }> {
if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') {
try {
const diffResponse = await giteaClient.repository.repoDownloadCommitDiffOrPatch({
const response = await giteaClient.repos.repoDownloadCommitDiffOrPatch(
owner,
repo,
sha: commitSha,
diffType: 'diff',
});
commitSha,
'diff'
);
return {
sha: commitSha,
diff: diffResponse.data,
diff: response.data,
};
} catch (error) {
core.error(`Failed to fetch Gitea/Forgejo commit diff: ${error}`);
@@ -75,6 +75,7 @@ async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff
}
interface DiffAndSHA {
sha: SHA;
diff: Diff;