Skip to content

Parsing error if there is/are git sub-repository #165

Open
@aBanhidy

Description

@aBanhidy

Dear Gentlemens!

I start to use your products and I think it is briliant! I am working on a project where there are 2 sub-repositories in the git repository.
If I start to use the $repository->getDiff() command it throws an excpetion because of sub-repositry change.

Only what I've chenged in your source code and it looks like work:
Diff parser:
Base:

            // 4. File informations
            $isBinary = false;
            if ($this->expects('index ')) {
                $oldIndex = $this->consumeShortHash();
                $this->consume('..');
                $newIndex = $this->consumeShortHash();
                if ($this->expects(' ')) {
                    $vars = $this->consumeRegexp('/\d{6}/');
                    $newMode = $oldMode = $vars[0];
                }
                $this->consumeNewLine();
            
                if ($this->expects('--- ')) {
                 	$oldName = $this->consumeTo("\n");
                        $this->consumeNewLine();
                        $this->consume('+++ ');
                        $newName = $this->consumeTo("\n");
                        $this->consumeNewLine();
                } elseif ($this->expects('Binary files ')) {
                        $vars = $this->consumeRegexp('/(.*) and (.*) differ\n/');
                        $isBinary = true;
                        $oldName = $vars[1];
                        $newName = $vars[2];
	         }
         }

Modified:

            // 4. File informations
            $isBinary = false;
            if ($this->expects('index ')) {
                $oldIndex = $this->consumeShortHash();
                $this->consume('..');
                $newIndex = $this->consumeShortHash();
                if ($this->expects(' ')) {
                    $vars = $this->consumeRegexp('/\d{6}/');
                    $newMode = $oldMode = $vars[0];
                }
                $this->consumeNewLine();
            }
            
            if ($this->expects('--- ')) {
            	$oldName = $this->consumeTo("\n");
                $this->consumeNewLine();
                $this->consume('+++ ');
                $newName = $this->consumeTo("\n");
                $this->consumeNewLine();
            } elseif ($this->expects('Binary files ')) {
                $vars = $this->consumeRegexp('/(.*) and (.*) differ\n/');
                $isBinary = true;
                $oldName = $vars[1];
                $newName = $vars[2];
	   }

...so I just move if ($this->expects('--- ')) { part out from condition: if ($this->expects('index ')) {

I am using version : ^1.2

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions