GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — node/tools/update-authors.js at master · InternAspitio/node Expand file tree/ Copy pathupdate-authors.jsMore file actions executable file ·96 lines (82 loc) · 2.94 KB / Copy pathupdate-authors.jsFile metadata and controlsexecutable file ·96 lines (82 loc) · 2.94 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 #!/usr/bin/env node // Usage: tools/update-author.js [--dry] // Passing --dry will redirect output to stdout rather than write to 'AUTHORS'. 'use strict'; const { spawn } = require('child_process'); const path = require('path'); const fs = require('fs'); const readline = require('readline'); class CaseIndifferentMap { _map = new Map(); get(key) { return this._map.get(key.toLowerCase()); } set(key, value) { return this._map.set(key.toLowerCase(), value); } } const log = spawn( 'git', // Inspect author name/email and body. ['log', '--reverse', '--format=Author: %aN <%aE>\n%b'], { stdio: ['inherit', 'pipe', 'inherit'] }); const rl = readline.createInterface({ input: log.stdout }); let output; if (process.argv.includes('--dry')) output = process.stdout; else output = fs.createWriteStream('AUTHORS'); output.write('# Authors ordered by first contribution.\n\n'); const mailmap = new CaseIndifferentMap(); { const lines = fs.readFileSync(path.resolve(__dirname, '../', '.mailmap'), { encoding: 'utf8' }).split('\n'); for (let line of lines) { line = line.trim(); if (line.startsWith('#') || line === '') continue; let match; // Replaced Name <[email protected]> if (match = line.match(/^([^<]+)\s+(<[^>]+>)$/)) { mailmap.set(match[2], { author: match[1] }); } else if (match = line.match(/^<([^>]+)>\s+(<[^>]+>)$/)) { mailmap.set(match[2], { email: match[1] }); // Replaced Name <[email protected]> <[email protected]> } else if (match = line.match(/^([^<]+)\s+(<[^>]+>)\s+(<[^>]+>)$/)) { mailmap.set(match[3], { author: match[1], email: match[2] }); // Replaced Name <[email protected]> Original Name <[email protected]> } else if (match = line.match(/^([^<]+)\s+(<[^>]+>)\s+([^<]+)\s+(<[^>]+>)$/)) { mailmap.set(match[3] + '\0' + match[4], { author: match[1], email: match[2] }); } else { console.warn('Unknown .mailmap format:', line); } } } const seen = new Set(); // Support regular git author metadata, as well as `Author:` and // `Co-authored-by:` in the message body. Both have been used in the past // to indicate multiple authors per commit, with the latter standardized // by GitHub now. const authorRe = /(^Author:|^Co-authored-by:)\s+(?<author>[^<]+)\s+(?<email><[^>]+>)/i; rl.on('line', (line) => { const match = line.match(authorRe); if (!match) return; let { author, email } = match.groups; const replacement = mailmap.get(author + '\0' + email) || mailmap.get(email); if (replacement) { ({ author, email } = { author, email, ...replacement }); } if (seen.has(email) || /@chromium\.org/.test(email) || return; } seen.add(email); output.write(`${author} ${email}\n`); }); rl.on('close', () => { output.end('\n# Generated by tools/update-authors.js\n'); }); |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |