Git Product home page Git Product logo

diff-parser's People

Contributors

anomiex avatar mre avatar ptlis avatar winternet-studio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mre juanmrad pgogy

diff-parser's Issues

getNewLineNo() and "No newline at end of file"

Hello! Git generated diff:

diff --git a/file.php b/file.php
index 272b2e4..7a9961d 100644
--- a/file.php
+++ b/file.php
@@ -1,3 +1,6 @@
 first line
 second line
-third line
\ No newline at end of file
+third line
+fourth line
+
+some other line

Current file content:

first line
second line
third line
fourth line

some other line

Display line numbers:

use ptlis\DiffParser\Parser;

$parser = new Parser();

$changeset = $parser->parseFile('C:/server/projects/dev/master-protect/git-line.diff', Parser::VCS_GIT);
$files = $changeset->getFiles();

foreach ($files as $file) {
    $hunks = $file->getHunks();
    foreach ($hunks as $hunk) {
        $lines = $hunk->getLines();

        foreach ($lines as $line) {
            echo 'getOriginalLineNo: ' . $line->getOriginalLineNo() . ' getNewLineNo: ' . $line->getNewLineNo() . ' ' . $line->getContent() . "\n";
        }
    }
}

Output:

getOriginalLineNo: 1 getNewLineNo: 1 first line
getOriginalLineNo: 2 getNewLineNo: 2 second line
getOriginalLineNo: 3 getNewLineNo: -1 third line
getOriginalLineNo: 4 getNewLineNo: 3  No newline at end of file
getOriginalLineNo: -1 getNewLineNo: 4 third line
getOriginalLineNo: -1 getNewLineNo: 5 fourth line
getOriginalLineNo: -1 getNewLineNo: 6
getOriginalLineNo: -1 getNewLineNo: 7 some other line

Why getNewLineNo() gets +1 for line number after "No newline at end of file"? I expected that "third line" is 3, "fourth line" is 4 and "some other line" is 6. Is this a mistake or do I understand something wrong?

PHP 8 Support

Would like to upgrade a project to PHP 8. Could you release a version that allows installing on PHP 8?

File creation and deletion not detected

Hi, there is an issue in detecting file modification type.

I've tried with diff containing added, changed and removed files but all files are detected as changed. I think the major issue comes from the UnifiedDiffTokenizer and the HUNK_START_REGEX which isn't working with SVN 1.8.

Moreover there is also an issue with the latest SVN version (1.9) which uses (nonexistent) for new files, not (revision 0).

SVN Diff - Undefined Offset: 0 - UnifiedDiffTokenizer.php line 258

When parsing a SVN diff with a svn property change causes an undefined offset 0 error.

Example SVN diff.

Index: branches/7.0/trunk
===================================================================
--- branches/7.0/trunk  (revision 115793)
+++ branches/7.0/trunk  (revision 115794)

Property changes on: branches/7.0/trunk
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /branches/7.0/dev/7.3.3-5959:r115410-115793
   Merged /branches/7.0/dev/7.3.2-5968:r115162-115780

------------------------------------------------------------------------

PHP 5.6 Support

Your project used to support php 5.6 on version 0.6.0 currently master only supports php 7+ is it possible to create a new branch where php 5.6 is still supported I need to create a PR with a fix on it and my current project is in php 5.6 I will also create the PR against master so the fix is in both branches.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.