项目作者: d4rkr00t

项目描述 :
Get a list of changed files
高级语言: JavaScript
项目地址: git://github.com/d4rkr00t/get-changed-files.git
创建时间: 2017-12-22T13:07:14Z
项目社区:https://github.com/d4rkr00t/get-changed-files

开源协议:

下载


Get Changed Files

Get a list of changed files using git.

Install

  1. npm intall get-changed-files --save-dev
  2. yarn add get-changed-files --dev

API

Simple usage

Without any options get-changed-files assumes that master is the main branch to compare it against current branch and also uses default strategy for determining diff point (point in history from which to start getting changes).

  1. const getChangedFiles = require("get-changed-files");
  2. getChangedFiles().then(results => console.log(results));
  3. /**
  4. * Outputs:
  5. * {
  6. * "changed": [
  7. * "some-old-changed-file.js",
  8. * "package.json",
  9. * "new-file.js"
  10. * ],
  11. * "uncommitted": [
  12. * "package.json"
  13. * ],
  14. * "untracked": [
  15. * "new-file.js"
  16. * ]
  17. * }
  18. */

Changing main branch

  1. const getChangedFiles = require("get-changed-files");
  2. getChangedFiles({ mainBranch: "develop" }).then(results =>
  3. console.log(results)
  4. );

Custom get diff point strategy

  1. const getChangedFiles = require("get-changed-files");
  2. const customGetDiffPoint = ({ currentBranch, mainBranch }) => {
  3. // do some magic...
  4. return { commit: commit_hash_from_which_to_start_getting_changes };
  5. };
  6. getChangedFiles({ customGetDiffPoint }).then(results => console.log(results));

CLI

Also get-changed-files adds a CLI tool get-changed.

  1. get-changed --help
  2. Get a list of changed files
  3. Usage
  4. $ get-changed
  5. Options
  6. --branch, -b Specify main branch [default: master].
  7. --only, -o Specify subset of results to be printed e.g. changed | uncommitted | untracked.
  8. --names Output file names only without any formatting. Can't be used with --json.
  9. --json Output result as json. Can't be used with --names-only.
  10. Examples
  11. $ get-changed --only=changed
  12. $ get-changed --json --only=changed
  13. $ get-changed --names-only