Skip to content

Instantly share code, notes, and snippets.

@guiofsaints
Forked from varemenos/1.README.md
Created November 1, 2021 18:28
Show Gist options
  • Save guiofsaints/3d341a224c2065251f9a9f0e99cd72e2 to your computer and use it in GitHub Desktop.
Save guiofsaints/3d341a224c2065251f9a9f0e99cd72e2 to your computer and use it in GitHub Desktop.

Revisions

  1. @varemenos varemenos revised this gist Jul 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 2.Example.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Here is an example in Javascript:
    Here is an example in Javascript based on a package I'm working on for Atom:

    ```js
    var format = '{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},';
  2. @varemenos varemenos revised this gist Jul 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 2.Example.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ new BufferedProcess({
    'log',
    '--pretty=format:' + format
    ],
    stdout: function (output) { commits += output; },
    stdout: function (chunk) { commits += chunk },
    exit: function (code) {
    if (code === 0) {
    var result = JSON.parse('[' + commits.slice(0, -1) + ']');
  3. @varemenos varemenos revised this gist Jul 11, 2015. 2 changed files with 4 additions and 5 deletions.
    5 changes: 3 additions & 2 deletions 1.README.md
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,7 @@ The only information that aren't fetched are:
    * `%B`: raw body (unwrapped subject and body)
    * `%GG`: raw verification message from GPG for a signed commit

    ---

    The format is applied to each line, so once you get all the lines, you need to remove the trailing `,` and wrap them around an Array.
    The format is applied to each line, so once you get all the lines, you need to remove the trailing `,` and wrap them around an Array.

    git log pretty format source: http://git-scm.com/docs/pretty-formats
    4 changes: 1 addition & 3 deletions 2.Example.md
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,4 @@ new BufferedProcess({
    }
    }
    });
    ```

    git log pretty format source: http://git-scm.com/docs/pretty-formats
    ```
  4. @varemenos varemenos revised this gist Jul 11, 2015. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  5. @varemenos varemenos renamed this gist Jul 11, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. @varemenos varemenos revised this gist Jul 11, 2015. 2 changed files with 26 additions and 25 deletions.
    25 changes: 25 additions & 0 deletions Example.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    Here is an example in Javascript:

    ```js
    var format = '{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},';

    var commits = [];

    new BufferedProcess({
    command: 'git',
    args: [
    'log',
    '--pretty=format:' + format
    ],
    stdout: function (output) { commits += output; },
    exit: function (code) {
    if (code === 0) {
    var result = JSON.parse('[' + commits.slice(0, -1) + ']');

    console.log(result); // valid JSON array
    }
    }
    });
    ```

    git log pretty format source: http://git-scm.com/docs/pretty-formats
    26 changes: 1 addition & 25 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -11,28 +11,4 @@ The only information that aren't fetched are:

    ---

    The format is applied to each line, so once you get all the lines, you need to remove the trailing `,` and wrap them around an Array. For example in Javascript:

    ```js
    var format = '{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},';

    var commits = [];

    new BufferedProcess({
    command: 'git',
    args: [
    'log',
    '--pretty=format:' + format
    ],
    stdout: function (output) { commits += output; },
    exit: function (code) {
    if (code === 0) {
    var result = JSON.parse('[' + commits.slice(0, -1) + ']');

    console.log(result); // valid JSON array
    }
    }
    });
    ```

    git log pretty format source: http://git-scm.com/docs/pretty-formats
    The format is applied to each line, so once you get all the lines, you need to remove the trailing `,` and wrap them around an Array.
  7. @varemenos varemenos revised this gist Jul 11, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@ The only information that aren't fetched are:
    * `%B`: raw body (unwrapped subject and body)
    * `%GG`: raw verification message from GPG for a signed commit

    ---

    The format is applied to each line, so once you get all the lines, you need to remove the trailing `,` and wrap them around an Array. For example in Javascript:

    ```js
  8. @varemenos varemenos revised this gist Jul 11, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,8 @@ git log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n

    The only information that aren't fetched are:

    * %B: raw body (unwrapped subject and body)
    * %GG: raw verification message from GPG for a signed commit
    * `%B`: raw body (unwrapped subject and body)
    * `%GG`: raw verification message from GPG for a signed commit

    The format is applied to each line, so once you get all the lines, you need to remove the trailing `,` and wrap them around an Array. For example in Javascript:

  9. @varemenos varemenos revised this gist Jul 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Get Git log in JSON format
    git log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},'
    ```

    The only information that's aren't fetched are:
    The only information that aren't fetched are:

    * %B: raw body (unwrapped subject and body)
    * %GG: raw verification message from GPG for a signed commit
  10. @varemenos varemenos revised this gist Jul 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Get git log in JSON format
    Get Git log in JSON format

    ```shell
    git log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},'
  11. @varemenos varemenos revised this gist Jul 11, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Get an (almost valid) JSON object out of git log
    Get git log in JSON format

    ```shell
    git log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},'
  12. @varemenos varemenos created this gist Jul 11, 2015.
    36 changes: 36 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    Get an (almost valid) JSON object out of git log

    ```shell
    git log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},'
    ```

    The only information that's aren't fetched are:

    * %B: raw body (unwrapped subject and body)
    * %GG: raw verification message from GPG for a signed commit

    The format is applied to each line, so once you get all the lines, you need to remove the trailing `,` and wrap them around an Array. For example in Javascript:

    ```js
    var format = '{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},';

    var commits = [];

    new BufferedProcess({
    command: 'git',
    args: [
    'log',
    '--pretty=format:' + format
    ],
    stdout: function (output) { commits += output; },
    exit: function (code) {
    if (code === 0) {
    var result = JSON.parse('[' + commits.slice(0, -1) + ']');

    console.log(result); // valid JSON array
    }
    }
    });
    ```

    git log pretty format source: http://git-scm.com/docs/pretty-formats