(sock: any, message: any)
| 9 | ownerOnly: true, |
| 10 | |
| 11 | async handler(sock: any, message: any) { |
| 12 | const chatId = message.key.remoteJid; |
| 13 | const git: any = (simpleGit as any)(); |
| 14 | |
| 15 | try { |
| 16 | const isRepo = await git.checkIsRepo(); |
| 17 | if (!isRepo) { |
| 18 | return sock.sendMessage(chatId, { text: '❌ This project is not a git repository.' }); |
| 19 | } |
| 20 | |
| 21 | const status = await git.status(); |
| 22 | const branch = status.current || 'unknown'; |
| 23 | const dirty = status.files.length > 0; |
| 24 | |
| 25 | const commitHash = (await git.revparse(['--short', 'HEAD'])).trim(); |
| 26 | |
| 27 | const ahead = status.ahead; |
| 28 | const behind = status.behind; |
| 29 | |
| 30 | const modifiedCount = status.files.length; |
| 31 | |
| 32 | const remotes = await git.getRemotes(true); |
| 33 | const remoteText = remotes.length |
| 34 | ? remotes.map((r: any) => `• ${r.name}: ${r.refs.fetch}`).join('\n') |
| 35 | : 'None'; |
| 36 | |
| 37 | const warning = dirty ? '⚠️ Warning: Working tree has uncommitted changes!' : ''; |
| 38 | |
| 39 | const text = |
| 40 | `📦 *Git Repository Info*\n\n` + |
| 41 | `🌿 Branch: ${branch}\n` + |
| 42 | `🔖 Commit: ${commitHash}\n` + |
| 43 | `🧼 Working tree: ${dirty ? 'Dirty' : 'Clean'}\n` + |
| 44 | `${dirty ? warning + '\n\n' : ''}` + |
| 45 | `📊 Ahead: ${ahead}, Behind: ${behind}\n` + |
| 46 | `📁 Modified/Untracked files: ${modifiedCount}\n\n` + |
| 47 | `🔗 Remotes:\n${remoteText}`; |
| 48 | |
| 49 | await sock.sendMessage(chatId, { text }); |
| 50 | |
| 51 | } catch(err: any) { |
| 52 | await sock.sendMessage(chatId, { text: `❌ Git error: ${err.message}` }); |
| 53 | } |
| 54 | } |
| 55 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected