Files: 01436b0a000173e48f00729b2c1f7b5b3cc4243d / modules / git-mini-messages.js
801 bytesRaw
1 | var h = require('../lib/h') |
2 | var when = require('@mmckegg/mutant/when') |
3 | var plugs = require('patchbay/plugs') |
4 | var message_link = plugs.first(exports.message_link = []) |
5 | |
6 | exports.message_content = exports.message_content_mini = function (msg, sbot) { |
7 | if (msg.value.content.type === 'git-update') { |
8 | var commits = msg.value.content.commits || [] |
9 | return [ |
10 | h('a', {href: `#${msg.key}`, title: commitSummary(commits)}, [ |
11 | 'pushed', |
12 | when(commits, [' ', pluralizeCommits(commits)]) |
13 | ]), |
14 | ' to ', |
15 | message_link(msg.value.content.repo) |
16 | ] |
17 | } |
18 | } |
19 | |
20 | function pluralizeCommits (commits) { |
21 | return when(commits.length === 1, '1 commit', `${commits.length} commits`) |
22 | } |
23 | |
24 | function commitSummary (commits) { |
25 | return commits.map(commit => `- ${commit.title}`).join('\n') |
26 | } |
27 |
Built with git-ssb-web