Refactor using gitea-js.
This commit is contained in:
+14
-12
@@ -48,34 +48,36 @@ async function getCommitDiff(commitSha: string): Promise<{ sha: SHA; diff: Diff
|
||||
'diff'
|
||||
);
|
||||
|
||||
return {
|
||||
sha: commitSha,
|
||||
diff: response.data,
|
||||
};
|
||||
const diff = response.data ?? '';
|
||||
if (!diff) {
|
||||
core.warning(`No diff data for commit ${commitSha}`);
|
||||
}
|
||||
|
||||
return { sha: commitSha, diff };
|
||||
} catch (error) {
|
||||
core.error(`Failed to fetch Gitea/Forgejo commit diff: ${error}`);
|
||||
core.error(`Error fetching Gitea/Forgejo 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 { 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 {
|
||||
sha: SHA;
|
||||
diff: Diff;
|
||||
|
||||
Reference in New Issue
Block a user