Refactor using gitea-js.
This commit is contained in:
+14
-11
@@ -18916,10 +18916,10 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
|||||||
command_1.issueCommand("error", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
command_1.issueCommand("error", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports2.error = error2;
|
exports2.error = error2;
|
||||||
function warning(message, properties = {}) {
|
function warning2(message, properties = {}) {
|
||||||
command_1.issueCommand("warning", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
command_1.issueCommand("warning", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports2.warning = warning;
|
exports2.warning = warning2;
|
||||||
function notice(message, properties = {}) {
|
function notice(message, properties = {}) {
|
||||||
command_1.issueCommand("notice", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
command_1.issueCommand("notice", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
@@ -93624,12 +93624,13 @@ async function getCommitDiff(commitSha) {
|
|||||||
commitSha,
|
commitSha,
|
||||||
"diff"
|
"diff"
|
||||||
);
|
);
|
||||||
return {
|
const diff2 = response.data ?? "";
|
||||||
sha: commitSha,
|
if (!diff2) {
|
||||||
diff: response.data
|
core.warning(`No diff data for commit ${commitSha}`);
|
||||||
};
|
}
|
||||||
|
return { sha: commitSha, diff: diff2 };
|
||||||
} catch (error2) {
|
} catch (error2) {
|
||||||
core.error(`Failed to fetch Gitea/Forgejo commit diff: ${error2}`);
|
core.error(`Error fetching Gitea/Forgejo diff for ${commitSha}: ${error2}`);
|
||||||
throw error2;
|
throw error2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93639,12 +93640,14 @@ async function getCommitDiff(commitSha) {
|
|||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
ref: commitSha,
|
ref: commitSha,
|
||||||
headers: {
|
headers: { Accept: "application/vnd.github.v3.diff" }
|
||||||
Accept: "application/vnd.github.v3.diff"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return { sha: commitSha, diff: diffResponse.data };
|
const diff = diffResponse.data ?? "";
|
||||||
|
if (!diff) {
|
||||||
|
core.warning(`No diff data from GitHub for commit ${commitSha}`);
|
||||||
|
}
|
||||||
|
return { sha: commitSha, diff };
|
||||||
}
|
}
|
||||||
async function improveMessagesInChunks(diffsAndSHAs) {
|
async function improveMessagesInChunks(diffsAndSHAs) {
|
||||||
const chunkSize = diffsAndSHAs.length % 2 === 0 ? 4 : 3;
|
const chunkSize = diffsAndSHAs.length % 2 === 0 ? 4 : 3;
|
||||||
|
|||||||
+14
-12
@@ -48,34 +48,36 @@ async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff
|
|||||||
'diff'
|
'diff'
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
const diff = response.data ?? '';
|
||||||
sha: commitSha,
|
if (!diff) {
|
||||||
diff: response.data,
|
core.warning(`No diff data for commit ${commitSha}`);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
return { sha: commitSha, diff };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.error(`Failed to fetch Gitea/Forgejo commit diff: ${error}`);
|
core.error(`Error fetching Gitea/Forgejo diff for ${commitSha}: ${error}`);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GitHub path unchanged
|
|
||||||
const diffResponse = await octokit.request<string>(
|
const diffResponse = await octokit.request<string>(
|
||||||
'GET /repos/{owner}/{repo}/commits/{ref}',
|
'GET /repos/{owner}/{repo}/commits/{ref}',
|
||||||
{
|
{
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
ref: commitSha,
|
ref: commitSha,
|
||||||
headers: {
|
headers: { Accept: 'application/vnd.github.v3.diff' },
|
||||||
Accept: 'application/vnd.github.v3.diff',
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return { sha: commitSha, diff: diffResponse.data };
|
const diff = diffResponse.data ?? '';
|
||||||
|
if (!diff) {
|
||||||
|
core.warning(`No diff data from GitHub for commit ${commitSha}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { sha: commitSha, diff };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface DiffAndSHA {
|
interface DiffAndSHA {
|
||||||
sha: SHA;
|
sha: SHA;
|
||||||
diff: Diff;
|
diff: Diff;
|
||||||
|
|||||||
Reference in New Issue
Block a user