Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8962497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:08:21+00:00 2026-06-15T16:08:21+00:00

I have spent two days researching for a library or some sort of PHP

  • 0

I have spent two days researching for a library or some sort of PHP function to parse the git patch GitHub’s API returns and I can’t find anything I can use.

I was able to take out a decent amount of code from Phabricator, but it just has too many dependencies.

Does anyone know of php code that will parse something like the following:

        commit d87635a1001a23d3a20422fcc8f2484b6bf3ab1b
        Author: Stav <st@gmail.com>
        Date:   Thu Dec 6 23:59:16 2012 +0200

            #666390 test chargify create and cancel subscription.

        diff --git a/.gitignore b/.gitignore
        index 796276b..b7fc8a1 100644
        --- a/.gitignore
        +++ b/.gitignore
        @@ -1,2 +1,3 @@
         application/config/config.php
        -application/config/database.php
        \ No newline at end of file
        +application/config/database.php
        +/local_file.php
        diff --git a/testing/Unit/libs/ChargifyTest.php b/testing/Unit/libs/ChargifyTest.php
        new file mode 100644
        index 0000000..f6ea674
        --- /dev/null
        +++ b/testing/Unit/libs/ChargifyTest.php
        @@ -0,0 +1,38 @@
        +<?php
        +
        +require_once dirname(__FILE__).'/../../../local_file.php';
        +

Into an html table like this:

phabricator parse tool

Thank you in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:08:22+00:00Added an answer on June 15, 2026 at 4:08 pm

    Here is what i’ve come up with.

            <? foreach( $commit['files'] as $file ) { ?>
            <div><h3><?=$file['filename']?></h3>
               <?
                $firstLine = true;
                $patch = explode("@@",$file['patch']);
                $lines_info = explode(",",$patch[1]);
                $st_ln_num = substr($lines_info[0], 2);
                $start_line['original'] = $st_ln_num;
                $start_line['left'] = $st_ln_num;
                $start_line['right'] = $st_ln_num;
                $lines = explode("\n",$file['patch']);
                ?>
                <div style="overflow: auto">
                <table class="parseDiff" cellpadding="0" cellspacing="0">
                    <? foreach ($lines as $line) {
                        if (! $firstLine) {
                                $line_left = "";
                                $line_right = "";
                                $char = strlen($line) ? $line[0] : '~';
                                $type = "neutral";
                                switch ($char) {
                                    case '-':
                                        $line_left = $start_line['left']++;
                                        $type = "removed";
                                        $line = $line;
                                        break;
                                    case '+':
                                        $line_right = $start_line['right']++;
                                        $type = "added";
                                        $line = $line;
                                        break;
                                    default:
                                        $line_left = $start_line['left']++;
                                        $line_right = $start_line['right']++;
                                        $type = "neutral";
                                        break;
                                }
                        ?>
                        <tr class="line-type-<?=$type?>">
                            <td class="line-number line-number-left"><?=$line_left?></td>
                            <td class="line-number line-number-right"><?=$line_right?></td>
                            <td class="line-code"><pre><?=htmlspecialchars($line)?></pre></td>
                        </tr>
                    <?
                        } else {
                    ?>
                        <tr class="line-type-first">
                            <td class="line-number  line-number-left">&middot;&middot;&middot;</td>
                            <td class="line-number  line-number-right">&middot;&middot;&middot;</td>
                            <td class="line-code"><pre><?=htmlspecialchars($line)?></pre></td>
                        </tr>
                    <?
                            $firstLine = false;
                        } // end if firstLine
                    } // end foreach
                    ?>
                </table>
                </div>
            </div>
        <? } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent several days now researching Hibernate and have several small questions about
I've spent two days on this and have gotten nowhere. I'm trying to use
Sorry for the long problem statement...I've spent two days debugging and have a lot
Please help as I have spent two days on this... I have a JSON
I've spent the last two days trying to get some bloody data to export
I am going to trash Entity Framework 5! I have spent two days to
I have spent the last two days reading up on this and ultimately have
I have spent the last two days looking for a simple javascript or jquery
I've spent two days trying to make a login/logout panel in PHP. I'm using
I spent around two hours on that problem, and I have visited these stackoverflow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.