Help us understand the problem. What is going on with this article?

gitでコミットしたファイルの一覧を取得

More than 5 years have passed since last update.
$ git log -1 --name-only

NodeJSで最新のコミットログから、コミットしたファイルの一覧を取得する

CoffeeScript
exec = require 'exec'

exec 'git log -1 --name-only', (obj, log)->
  lines = log.split('\n')
  commit = lines.shift().replace(/^commit /, '')
  author = lines.shift().replace(/^Author:\s+/, '')
  date = lines.shift().replace(/^Date:\s+/, '')
  lines.shift()

  files = []
  while true
    file = lines.pop()
    if file
      files.unshift(file)
    else 
      break

  comment = lines.join('\n')
  comment = comment.replace(/^\s{4}/g, '')

  item =
    commit: commit
    author: author
    date: new Date(date)
    files: files
    comment: comment

  console.log JSON.stringify(item, null, '  ')
seyself
bascule
DATA × TECHNOLOGY × DESIGN
http://www.bascule.co.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away