Personal Telegram developer console for GitHub
feat(github): add source-backed commit detail
davoodmehraban89 committed
Oct 4, 2026 at 17:43 UTC
e31ff5ca6ab6301fe7ef51f85d959c56c18fbe68
1 file changed
+29
-2
src/github.js
+29
-2
@@ -219,11 +219,38 @@ export class GitHubService {
219
const { apiBase } = await this.getRepositoryContext(repoRef);
220
const data = await this.requestJson(`${apiBase}/commits?per_page=5`, 'GitHub commits');
221
return data.map(c => ({
222
- sha: c.sha.slice(0, 7), message: String(c.commit?.message || '').split('\n')[0],
223
- author: c.author?.login || c.commit?.author?.name || 'Unknown', date: c.commit?.author?.date ? c.commit.author.date.slice(0, 10) : ''
222
+ sha: String(c.sha || '').slice(0, 7),
223
+ fullSha: String(c.sha || ''),
224
+ message: String(c.commit?.message || '').split('\n')[0],
225
+ author: c.author?.login || c.commit?.author?.name || 'Unknown',
226
+ date: c.commit?.author?.date ? c.commit.author.date.slice(0, 10) : ''
227
}));
228
}
229
230
+ async getCommit(repoRef, sha) {
231
+ const commitSha = fullSha(sha);
232
+ const { apiBase } = await this.getRepositoryContext(repoRef);
233
+ const c = await this.requestJson(`${apiBase}/commits/${commitSha}`, 'GitHub commit');
234
+ const files = (c.files || []).slice(0, 20).map(file => ({
235
+ filename: file.filename || '',
236
+ status: file.status || '',
237
+ additions: file.additions ?? 0,
238
+ deletions: file.deletions ?? 0,
239
+ changes: file.changes ?? 0
240
+ }));
241
+ return {
242
+ sha: commitSha,
243
+ shortSha: commitSha.slice(0, 7),
244
+ message: String(c.commit?.message || ''),
245
+ author: c.author?.login || c.commit?.author?.name || 'Unknown',
246
+ date: c.commit?.author?.date || '',
247
+ additions: c.stats?.additions ?? 0,
248
+ deletions: c.stats?.deletions ?? 0,
249
+ changedFiles: files.length,
250
+ files
251
+ };
252
+ }
253
+
254
async listCommitChecks(repoRef, sha, { perPage = 20, page = 1 } = {}) {
255
const commitSha = fullSha(sha); const count = clampPerPage(perPage, 20); const pageNumber = clampPage(page);
256
const { apiBase } = await this.getRepositoryContext(repoRef);