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", axios: "^1.3.4",
chalk: "^5.2.0", chalk: "^5.2.0",
cleye: "^1.3.2", cleye: "^1.3.2",
"cross-fetch": "^4.1.0",
crypto: "^1.0.1", crypto: "^1.0.1",
execa: "^7.0.0", execa: "^7.0.0",
"gitea-js": "^1.23.0",
ignore: "^5.2.4", ignore: "^5.2.4",
ini: "^3.0.1", ini: "^3.0.1",
inquirer: "^9.1.4", 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 { generateCommitMessageByDiff } from './generateCommitMessageFromGitDiff';
import { randomIntFromInterval } from './utils/randomIntFromInterval'; import { randomIntFromInterval } from './utils/randomIntFromInterval';
import { sleep } from './utils/sleep'; 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. // This should be a token with access to your repository scoped in as a secret.
const GITHUB_TOKEN = core.getInput('GITHUB_TOKEN'); 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 // Initialize platform-specific clients
let octokit: ReturnType<typeof github.getOctokit>; 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') { if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') {
// Dynamically import the Gitea client
try { try {
const gitea = require('@go-gitea/sdk.js').ApiClient; giteaClient = giteaApi(GITEA_URL, {
giteaClient = new gitea({ token: GITHUB_TOKEN,
baseUrl: GITEA_URL, customFetch: fetch,
auth: GITHUB_TOKEN,
}); });
} catch (error) { } catch (error) {
core.error(`Failed to import Gitea client: ${error}`); core.error(`Failed to import/initialize Gitea client: ${error}`);
throw error; throw error;
} }
} else { } else {
@@ -41,16 +41,16 @@ type Diff = string;
async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff }> { async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff }> {
if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') { if (PLATFORM === 'gitea' || PLATFORM === 'forgejo') {
try { try {
const diffResponse = await giteaClient.repository.repoDownloadCommitDiffOrPatch({ const response = await giteaClient.repos.repoDownloadCommitDiffOrPatch(
owner, owner,
repo, repo,
sha: commitSha, commitSha,
diffType: 'diff', 'diff'
}); );
return { return {
sha: commitSha, sha: commitSha,
diff: diffResponse.data, diff: response.data,
}; };
} catch (error) { } catch (error) {
core.error(`Failed to fetch Gitea/Forgejo commit diff: ${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 { interface DiffAndSHA {
sha: SHA; sha: SHA;
diff: Diff; diff: Diff;