How to use parse-diff - 6 common examples

To help you get started, we’ve selected a few parse-diff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danger / danger-js / source / platforms / git / diffToGitJSONDSL.ts View on Github external
export const diffToGitJSONDSL = (diff: string, commits: GitCommit[]): GitJSONDSL => {
  const fileDiffs: any[] = parseDiff(diff)

  const addedDiffs = fileDiffs.filter((diff: any) => diff["new"])
  const removedDiffs = fileDiffs.filter((diff: any) => diff["deleted"])
  const modifiedDiffs = fileDiffs.filter((diff: any) => !includes(addedDiffs, diff) && !includes(removedDiffs, diff))

  return {
    //                                             Work around for danger/danger-js#807
    modified_files: modifiedDiffs.map(d => d.to || (d.from && d.from.split(" b/")[0])),
    created_files: addedDiffs.map(d => d.to),
    deleted_files: removedDiffs.map(d => d.from),
    commits: commits,
  }
}
github apache / incubator-weex / dangerfile.js View on Github external
function parseDeleteAndNormalLines(diffData, fileToDeletedLinesMap, fileToNormalLinesMap) {
  try {
    console.log('parseDeleteAndNormalLines')
    var diffs = parseDiff(diffData)
    console.log('diffs:'+diffs)
    if(diffs&&diffs instanceof Array){
      diffs.forEach(diff => {
        fileToDeletedLinesMap[diff.from] = [];
        fileToNormalLinesMap[diff.from] = [];
        if(diff&&diff.chunks&&diff.chunks instanceof Array){
          diff.chunks.forEach(chunk => {
            if(chunk&&chunk.changes&&chunk.changes instanceof Array){
              chunk.changes.forEach(change => {
                if (change&&change.del) {
                  fileToDeletedLinesMap[diff.from].push(change.ln)
                }
                if (change&&change.normal) {
                  fileToNormalLinesMap[diff.from].push(change.ln1)
                }
              })
github gitpoint / git-point / src / repository / screens / pull-diff.screen.js View on Github external
renderHeader = () => {
    const { navigation } = this.props;
    const { locale, diff } = navigation.state.params;

    const filesChanged = Parse(diff);

    let lineAdditions = 0;
    let lineDeletions = 0;

    filesChanged.forEach(file => {
      lineAdditions += file.additions;
      lineDeletions += file.deletions;
    });

    return (
github danger / danger-js / source / platforms / git / gitJSONToGitDSL.ts View on Github external
const structuredDiffForFile = async (filename: string): Promise => {
    let fileDiffs: GitStructuredDiff

    if (config.getStructuredDiffForFile) {
      fileDiffs = await config.getStructuredDiffForFile(config.baseSHA, config.headSHA, filename)
    } else {
      const diff = await getFullDiff!(config.baseSHA, config.headSHA)
      fileDiffs = parseDiff(diff)
    }
    const structuredDiff = fileDiffs.find(diff => diff.from === filename || diff.to === filename)
    if (structuredDiff !== undefined && structuredDiff.chunks !== undefined) {
      return { chunks: structuredDiff.chunks }
    } else {
      return null
    }
  }
github gitpoint / git-point / src / repository / screens / pull-diff.screen.js View on Github external
render() {
    const { navigation } = this.props;
    const filesChanged = navigation.state.params
      ? Parse(navigation.state.params.diff)
      : [];

    return (
      
        
      
    );
  }
}
github gitpoint / git-point / src / components / issue-description.component.js View on Github external
diff,
      issue,
      commits,
      repository,
      isMergeable,
      isMerged,
      isPendingDiff,
      isPendingCommit,
      isPendingCheckMerge,
      onRepositoryPress,
      userHasPushPermission,
      locale,
      navigation,
    } = this.props;

    const filesChanged = Parse(diff);

    let lineAdditions = 0;
    let lineDeletions = 0;

    filesChanged.forEach(file => {
      lineAdditions += file.additions;
      lineDeletions += file.deletions;
    });

    return (
      
        {issue.repository_url && (

parse-diff

Unified diff parser

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Popular parse-diff functions