"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/scripts/changelog.js" (7 Feb 2017, 2953 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict'
    2 /*
    3 Usage:
    4 
    5 node scripts/changelog.js [comittish]
    6 
    7 Generates changelog entries in our format as best as its able based on
    8 commits starting at comittish, or if that's not passed, master.
    9 
   10 Ordinarily this is run via the gen-changelog shell script, which appends
   11 the result to the changelog.
   12 
   13 */
   14 const execSync = require('child_process').execSync
   15 const branch = process.argv[2] || 'master'
   16 const log = execSync(`git log --pretty='format:%h %H%d %s (%aN)%n%b%n---%n' ${branch}...`).toString().split(/\n/)
   17 const authormap = {
   18   'Rebecca Turner': 'iarna',
   19   'Forrest L Norvell': 'othiym23',
   20   'Kyle Mitchell': 'kemitchell',
   21   'Chris Rebert': 'cvrebert',
   22   'Kat Marchán': 'zkat'
   23 }
   24 
   25 main()
   26 
   27 function print_commit (c) {
   28   let m
   29   console.log(`* [\`${c.shortid}\`](https://github.com/npm/npm/commit/${c.fullid})`)
   30   if (c.fixes) {
   31     console.log(`  [#${c.fixes}](https://github.com/npm/npm/issues/${c.fixes})`)
   32   } else if (c.prurl && (m = c.prurl.match(/https:\/\/github.com\/([^/]+\/[^/]+)\/pull\/(\d+)/))) {
   33     let repo = m[1]
   34     let prid = m[2]
   35     if (repo !== 'npm/npm') {
   36       console.log(`  [${repo}#${prid}](${c.prurl})`)
   37     } else {
   38       console.log(`  [#${prid}](${c.prurl})`)
   39     }
   40   } else if (c.prurl) {
   41     console.log(`  [#](${c.prurl})`)
   42   }
   43   let msg = c.message
   44     .replace(/^\s+/mg, '')
   45     .replace(/^[-a-z]+: /, '')
   46     .replace(/^/mg, '  ')
   47     .replace(/\n$/, '')
   48   // backtickify package@version
   49     .replace(/^(\s*[^@\s]+@\d+[.]\d+[.]\d+)(\s*\S)/g, '$1:$2')
   50     .replace(/\b([^@\s]+@\d+[.]\d+[.]\d+)\b/g, '`$1`')
   51   // linkify commitids
   52     .replace(/\b([a-f0-9]{7,8})\b/g, '[`$1`](https://github.com/npm/npm/commit/$1)')
   53     .replace(/\b#(\d+)\b/g, '[#$1](https://github.com/npm/npm/issues/$1)')
   54   console.log(msg)
   55   if (c.credit) {
   56     c.credit.forEach(function (credit) {
   57       console.log(`  ([@${credit}](https://github.com/${credit}))`)
   58     })
   59   } else {
   60     console.log(`  ([@${c.author}](https://github.com/${c.author}))`)
   61   }
   62 }
   63 
   64 function main () {
   65   let commit
   66   log.forEach(function (line) {
   67     let m
   68     /*eslint no-cond-assign:0*/
   69     if (/^---$/.test(line)) {
   70       print_commit(commit)
   71     } else if (m = line.match(/^([a-f0-9]{7}) ([a-f0-9]+) (?:[(]([^)]+)[)] )?(.*?) [(](.*?)[)]/)) {
   72       commit = {
   73         shortid: m[1],
   74         fullid: m[2],
   75         branch: m[3],
   76         message: m[4],
   77         author: authormap[m[5]] || m[5],
   78         prurl: null,
   79         fixes: null,
   80         credit: null
   81       }
   82     } else if (m = line.match(/^PR-URL: (.*)/)) {
   83       commit.prurl = m[1]
   84     } else if (m = line.match(/^Credit: @(.*)/)) {
   85       if (!commit.credit) commit.credit = []
   86       commit.credit.push(m[1])
   87     } else if (m = line.match(/^Fixes: (?:#|https:[/][/]github.com[/]npm[/]npm[/]issues[/])(.*)/)) {
   88       commit.fixes = m[1]
   89     } else if (m = line.match(/^Reviewed-By: @(.*)/)) {
   90       commit.reviewed = m[1]
   91     } else if (/\S/.test(line)) {
   92       commit.message += `\n${line}`
   93     }
   94   })
   95 }