"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/scripts/changelog.js" (31 May 2018, 2955 Bytes) of package /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, latest.
    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] || 'origin/latest'
   16 const log = execSync(`git log --reverse --pretty='format:%h %H%d %s (%aN)%n%b%n---%n' ${branch}...`).toString().split(/\n/)
   17 
   18 main()
   19 
   20 function shortname (url) {
   21   let matched = url.match(/https:\/\/github.com\/([^/]+\/[^/]+)\/(?:pull|issues)\/(\d+)/)
   22   if (!matched) return false
   23   let repo = matched[1]
   24   let id = matched[2]
   25   if (repo !== 'npm/npm') {
   26     return `${repo}#${id}`
   27   } else {
   28     return `#${id}`
   29   }
   30 }
   31 
   32 function print_commit (c) {
   33   console.log(`* [\`${c.shortid}\`](https://github.com/npm/npm/commit/${c.fullid})`)
   34   if (c.fixes) {
   35     let label = shortname(c.fixes)
   36     if (label) {
   37       console.log(`  [${label}](${c.fixes})`)
   38     } else {
   39       console.log(`  [#${c.fixes}](https://github.com/npm/npm/issues/${c.fixes})`)
   40     }
   41   } else if (c.prurl) {
   42     let label = shortname(c.prurl)
   43     if (label) {
   44       console.log(`  [${label}](${c.prurl})`)
   45     } else {
   46       console.log(`  [#](${c.prurl})`)
   47     }
   48   }
   49   let msg = c.message
   50     .replace(/^\s+/mg, '')
   51     .replace(/^[-a-z]+: /, '')
   52     .replace(/^/mg, '  ')
   53     .replace(/\n$/, '')
   54   // backtickify package@version
   55     .replace(/^(\s*[^@\s]+@\d+[.]\d+[.]\d+)(\s*\S)/g, '$1:$2')
   56     .replace(/\b([^@\s]+@\d+[.]\d+[.]\d+)\b/g, '`$1`')
   57   // linkify commitids
   58     .replace(/\b([a-f0-9]{7,8})\b/g, '[`$1`](https://github.com/npm/npm/commit/$1)')
   59     .replace(/\b#(\d+)\b/g, '[#$1](https://github.com/npm/npm/issues/$1)')
   60   console.log(msg)
   61   if (c.credit) {
   62     c.credit.forEach(function (credit) {
   63       console.log(`  ([@${credit}](https://github.com/${credit}))`)
   64     })
   65   } else {
   66     console.log(`  ([@${c.author}](https://github.com/${c.author}))`)
   67   }
   68 }
   69 
   70 function main () {
   71   let commit
   72   log.forEach(function (line) {
   73     let m
   74     /*eslint no-cond-assign:0*/
   75     if (/^---$/.test(line)) {
   76       print_commit(commit)
   77     } else if (m = line.match(/^([a-f0-9]{7}) ([a-f0-9]+) (?:[(]([^)]+)[)] )?(.*?) [(](.*?)[)]/)) {
   78       commit = {
   79         shortid: m[1],
   80         fullid: m[2],
   81         branch: m[3],
   82         message: m[4],
   83         author: m[5],
   84         prurl: null,
   85         fixes: null,
   86         credit: null
   87       }
   88     } else if (m = line.match(/^PR-URL: (.*)/)) {
   89       commit.prurl = m[1]
   90     } else if (m = line.match(/^Credit: @(.*)/)) {
   91       if (!commit.credit) commit.credit = []
   92       commit.credit.push(m[1])
   93     } else if (m = line.match(/^Fixes: #?(.*?)/)) {
   94       commit.fixes = m[1]
   95     } else if (m = line.match(/^Reviewed-By: @(.*)/)) {
   96       commit.reviewed = m[1]
   97     } else if (/\S/.test(line)) {
   98       commit.message += `\n${line}`
   99     }
  100   })
  101 }