Options
All
  • Public
  • Public/Protected
  • All
Menu

Module git-changes-affected

git-changes-affected

Find git changes affected files

Quick start

Intalling via npm:

npm i git-changes-affected

Fnd what modules your last commit change affects by:

const gitChangesAffected = require('git-changes-affected');
gitChangesAffected();

Find impact of changes by certain commit:

gitChangesAffected({
  to: '59037780a46c5000830a7a6705ebfa82d5a30095'
});

Find impact of changes between 2 revisions:

gitChangesAffected({
  to: '59037780a46c5000830a7a6705ebfa82d5a30095',
  from: '8e0d337483f9c9db07deeb2d82d7a8b3f8515423'
});

If your repo uses special supports like JSX, flow, typescript, etc., you will need to enable @babel/parser plugins as following:

gitChangesAffected({
  parserOptions: {
    plugins: ['jsx', 'typescript']
  }
});

Index

References

Change

Re-exports Change

DEFAULT_EXTENSIONS

Re-exports DEFAULT_EXTENSIONS

Diff

Re-exports Diff

GIT_OPERATION

Re-exports GIT_OPERATION

default

Renames and re-exports gitChangesAffected

getChangedEntries

Re-exports getChangedEntries

getGitDiffs

Re-exports getGitDiffs

huntRevisionImpact

Re-exports huntRevisionImpact

Type aliases

Change

Change: { changed: Array<{ end: number; start: number }>; content: string | null; file: string }

Type declaration

  • changed: Array<{ end: number; start: number }>

    Changed file code line ranges

  • content: string | null
  • file: string

    File path relative to the repo

Diff

Diff: { operation: GIT_OPERATION; source: Change; target: Change }

Type declaration

Options

Options: { alias?: undefined | {}; extensions?: string[]; modules?: string[]; parserOptions?: ParserOptions; paths?: string[] }

Type declaration

  • Optional alias?: undefined | {}

    Module alias to a path

  • Optional extensions?: string[]

    Filter file extensions, default value: ['.js', '.jsx', '.ts', '.tsx].

  • Optional modules?: string[]

    Paths where to look for JS modules, if you have customised modules other than npm's node_modules.

  • Optional parserOptions?: ParserOptions

    @babel/parser options for parsing file to AST

  • Optional paths?: string[]

    Limit paths of tracked files to check with. By default it will check all the git tracked files.

Options

Options: HuntRevisionImpactOptions & { from?: undefined | string; to?: undefined | string }

Variables

Const DEFAULT_EXTENSIONS

DEFAULT_EXTENSIONS: string[] = ['.js', '.jsx', '.ts', '.tsx']

Functions

getAbsolutePath

  • getAbsolutePath(relativePath: string): string

getChangedEntries

  • getChangedEntries(changes: Change[], parserOptions?: ParserOptions | null): Entry[]
  • Find what declarations does the code line changes belong to.

    Parameters

    • changes: Change[]
    • Optional parserOptions: ParserOptions | null

      @babel/parser options

    Returns Entry[]

    A list of object contains module absolute path and declaration name

getGitDiffs

  • getGitDiffs(to: string, from?: undefined | string): Diff[]

getRevisionFile

  • getRevisionFile(revision: string, file: string): string

getTrackedFiles

  • getTrackedFiles(revision?: string, paths?: string[]): string[]

gitChangesAffected

gitRoot

  • gitRoot(): string

hasExt

  • hasExt(file: string, extensions: string[]): boolean

huntRevisionImpact

  • huntRevisionImpact(revision: string, changes: Change[], __namedParameters: { alias: undefined | {}; extensions: undefined | string[]; modules: undefined | string[]; parserOptions: undefined | ParserOptions; paths: undefined | string[] }): Promise<Affected>
  • Find what module declarations will be affected by changing given code lines in given git revision context.

    Parameters

    • revision: string

      Git revision

    • changes: Change[]
    • __namedParameters: { alias: undefined | {}; extensions: undefined | string[]; modules: undefined | string[]; parserOptions: undefined | ParserOptions; paths: undefined | string[] }
      • alias: undefined | {}
      • extensions: undefined | string[]
      • modules: undefined | string[]
      • parserOptions: undefined | ParserOptions
      • paths: undefined | string[]

    Returns Promise<Affected>

Generated using TypeDoc