项目作者: Equip-Collaboration

项目描述 :
This action outputs the line number of the deleted/added lines of modified or added files.
高级语言: JavaScript
项目地址: git://github.com/Equip-Collaboration/diff-line-numbers.git
创建时间: 2021-04-14T16:12:07Z
项目社区:https://github.com/Equip-Collaboration/diff-line-numbers

开源协议:

下载


Diff line numbers javascript action

This action outputs the line number of the deleted/added lines of modified or added files.

The line numbers are obtained by parsing the patch chunks of each file given by git diff

NOTE: Requires having used actions/checkout@v3 in a previous step.

Inputs

include

Optional JSON array. Only process paths that match a regular expression in include. By default includes all.

ignore

Optional JSON array. Do not process paths that match a regular expression in ignore. By default ignores none.

Outputs

lineNumbers

An array with the files’ path, added lines and removed lines. It looks like:

  1. [
  2. {
  3. path: string,
  4. added: number[],
  5. removed: number[]
  6. },
  7. ...
  8. ]
  • path is the file’s path, e.g. package.json and src/index.js.
  • added is an array of numbers. Each number is the line number of an added line.
  • removed is an array of numbers. Each number is the line number of a removed line.

Example usage

  1. name: example
  2. on: [pull_request]
  3. jobs:
  4. example:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - name: Get diff lines
  8. id: diff
  9. uses: Equip-Collaboration/diff-line-numbers@v1
  10. with:
  11. include: '["\\.js$", "\\.jsx$"]'
  12. ignore: '["^dist/", "^bin/", "^www/"]'
  13. - name: Print line numbers of changed lines
  14. run: echo Line numbers = ${{ toJSON(steps.diff.outputs.lineNumbers) }}