Skip to content

Instantly share code, notes, and snippets.

@joaoneto
Last active December 11, 2015 23:48

Revisions

  1. joaoneto revised this gist Jun 22, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions changelog.php
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    * To use, set executable permissions to this file and execute:
    * $ php changelog.php > CHANGELOG.md
    *
    * Copyright (c) 2013 João Pinto Neto
    * Copyright (c) 2014 João Pinto Neto
    * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
    *
    *
    @@ -21,7 +21,7 @@
    if (!isset($result[$match[1]])) {
    $result[$match[1]] = array();
    }
    $result[$match[1]][] = $match[4];
    $result[$match[1]][] = $match[4] . ' (by ' . $match[2] . ' '. $match[3] . ')';
    }
    }

  2. joaoneto revised this gist Feb 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion changelog.php
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    * This is a script to transform GIT LOG into a cute format Changelog.md
    *
    * To use, set executable permissions to this file and execute:
    * $ php changelog.php > CHANGELOG.mg
    * $ php changelog.php > CHANGELOG.md
    *
    * Copyright (c) 2013 João Pinto Neto
    * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
  3. joaoneto revised this gist Jan 31, 2013. No changes.
  4. joaoneto created this gist Jan 31, 2013.
    35 changes: 35 additions & 0 deletions changelog.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <?php
    /**
    * Changelog Markdown
    *
    * This is a script to transform GIT LOG into a cute format Changelog.md
    *
    * To use, set executable permissions to this file and execute:
    * $ php changelog.php > CHANGELOG.mg
    *
    * Copyright (c) 2013 João Pinto Neto
    * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
    *
    *
    */
    $cmd = 'git log --pretty="%ad: [%an] <%ae> %s" --date="short" --no-merges';
    $process = shell_exec($cmd);
    $result = array();

    foreach (preg_split("/((\r?\n)|(\r\n?))/", $process) as $line) {
    if (preg_match('/(^\d{4}-\d{2}-\d{2})\:\s\[(.*)\]\s(\<.*\>)\s(.*)/', $line, $match)) {
    if (!isset($result[$match[1]])) {
    $result[$match[1]] = array();
    }
    $result[$match[1]][] = $match[4];
    }
    }

    echo '# Changelog' . PHP_EOL;
    foreach ($result as $date => $data) {
    echo '## ' . $date . PHP_EOL;
    foreach ($data as $change) {
    echo '- ' . $change . PHP_EOL;
    }
    echo PHP_EOL;
    }