MCPcopy
hub / github.com/refined-github/refined-github / add

Function add

source/features/pr-commit-lines-changed.tsx:43–62  ·  view source on GitHub ↗
(commitHash: HTMLElement)

Source from the content-addressed store, hash-verified

41}
42
43async function add(commitHash: HTMLElement): Promise<void> {
44 const commitSha = location.pathname.split('/').pop()!;
45 const [additions, deletions] = await commitChanges.get(commitSha);
46 const tooltip = pluralize(additions + deletions, '1 line changed', '$$ lines changed');
47 const {green, red, gray} = calculateDiffSquareCounts(additions, deletions);
48 commitHash.prepend(
49 tooltipped(
50 tooltip,
51 <span className="ml-2 tmp-ml-2 d-md-block d-none diffstat">
52 <span className="color-fg-success">+{additions}</span>
53 {' '}
54 <span className="color-fg-danger">−{deletions}</span>
55 {' '}
56 {repeatItems(green, () => <span className="diffstat-block-added" />)}
57 {repeatItems(red, () => <span className="diffstat-block-deleted" />)}
58 {repeatItems(gray, () => <span className="diffstat-block-neutral" />)}
59 </span>,
60 ),
61 );
62}
63
64async function init(signal: AbortSignal): Promise<void> {
65 observe('[class*="__CommitAttributionContainer"] + .text-mono', add, {signal});

Callers

nothing calls this directly

Calls 6

pluralizeFunction · 0.85
tooltippedFunction · 0.85
repeatItemsFunction · 0.85
getMethod · 0.80
prependMethod · 0.80

Tested by

no test coverage detected