Parsing Git Log

    Let’s parse git log

    Let’s make it more parsable

    1. > git log --pretty="%h|%s|%aN|%aE|%aD" -n 25

    This will work but I’ve been burnt by this in the past when a pipe | gets injected in the commits.

    So, let’s try again with something that most likely won’t show up in commits, »¦«. Also, since we’re not using a pipe now we don’t have to use quotes around the pretty format string. Notice that the output is just a bunch of strings.

    1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 5
    1. 42f1874a»¦«Update some examples and docs (#4682)»¦«Justin Ma»¦«hustcer@outlook.com»¦«Tue, 1 Mar 2022 21:05:29 +0800
    2. 2a89936b»¦«Move to latest stable crossterm, with fix (#4684)»¦«JT»¦«547158+jntrnr@users.noreply.github.com»¦«Tue, 1 Mar 2022 07:05:46 -0500
    3. ece5e7db»¦«dataframe list command (#4681)»¦«Fernando Herrera»¦«fernando.j.herrera@gmail.com»¦«Tue, 1 Mar 2022 11:41:13 +0000
    4. a6a96b29»¦«Add binary literals (#4680)»¦«JT»¦«547158+jntrnr@users.noreply.github.com»¦«Mon, 28 Feb 2022 18:31:53 -0500
    5. e3100e6a»¦«Fix alias in `docs/sample_config/config.toml` (#4669)»¦«Luca Trevisani»¦«lucatrv@hotmail.com»¦«Mon, 28 Feb 2022 22:47:14 +0100

    Ahh, much better. Now that we have the raw data, let’s try to parse it with nu.

    First we need to get it in lines or rows. Notice that the output is now in a table format.

    1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 5 | lines
    1. ───┬─────────────────────────────────────────────────────────────────────────────────────────────────
    2. 0 42f1874a»¦«Update some examples and docs (#4682)»¦«Justin Ma»¦«hustcer@outlook.com»¦«Tue, 1 Mar
    3. 2022 21:05:29 +0800
    4. 1 2a89936b»¦«Move to latest stable crossterm, with fix
    5. (#4684)»¦«JT»¦«547158+jntrnr@users.noreply.github.com»¦«Tue, 1 Mar 2022 07:05:46 -0500
    6. 2 ece5e7db»¦«dataframe list command (#4681)»¦«Fernando
    7. Herrera»¦«fernando.j.herrera@gmail.com»¦«Tue, 1 Mar 2022 11:41:13 +0000
    8. 3 a6a96b29»¦«Add binary literals (#4680)»¦«JT»¦«547158+jntrnr@users.noreply.github.com»¦«Mon, 28
    9. Feb 2022 18:31:53 -0500
    10. 4 e3100e6a»¦«Fix alias in `docs/sample_config/config.toml` (#4669)»¦«Luca
    11. Trevisani»¦«lucatrv@hotmail.com»¦«Mon, 28 Feb 2022 22:47:14 +0100
    12. ───┴─────────────────────────────────────────────────────────────────────────────────────────────────

    That’s more like nushell, but it would be nice to have some columns.

    We used the delimiter »¦« specifically so we can create columns so let’s use it like this.

    1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 5 | lines | split column "»¦«"
    1. ───┬──────────┬──────────────────────┬──────────────────┬──────────────────────┬──────────────────
    2. # │ column1 │ column2 │ column3 │ column4 │ column5
    3. ───┼──────────┼──────────────────────┼──────────────────┼──────────────────────┼──────────────────
    4. 0 42f1874a Update some examples Justin Ma hustcer@outlook.com Tue, 1 Mar 2022
    5. and docs (#4682) 21:05:29 +0800
    6. 1 2a89936b Move to latest JT 547158+jntrnr@users. Tue, 1 Mar 2022
    7. stable crossterm, noreply.github.com 07:05:46 -0500
    8. with fix (#4684)
    9. 2 ece5e7db dataframe list Fernando Herrera fernando.j.herrera@g Tue, 1 Mar 2022
    10. command (#4681) mail.com 11:41:13 +0000
    11. 3 a6a96b29 Add binary literals JT 547158+jntrnr@users. Mon, 28 Feb 2022
    12. (#4680) noreply.github.com 18:31:53 -0500
    13. 4 e3100e6a Fix alias in Luca Trevisani lucatrv@hotmail.com Mon, 28 Feb 2022
    14. `docs/sample_config/ │ │ │ 22:47:14 +0100
    15. │ │ config.toml`
    16. (#4669)
    17. ───┴──────────┴──────────────────────┴──────────────────┴──────────────────────┴──────────────────

    Yay, for columns! But wait, it would really be nice if those columns had something other than generically named column names.

    1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 5 | lines | split column "»¦«" commit subject name email date

    Ahhh, that looks much better.

    1. ───┬──────────┬──────────────────────┬──────────────────┬──────────────────────┬──────────────────
    2. # │ commit │ subject │ name │ email │ date
    3. ───┼──────────┼──────────────────────┼──────────────────┼──────────────────────┼──────────────────
    4. 0 42f1874a Update some examples Justin Ma hustcer@outlook.com Tue, 1 Mar 2022
    5. and docs (#4682) 21:05:29 +0800
    6. 1 2a89936b Move to latest JT 547158+jntrnr@users. Tue, 1 Mar 2022
    7. stable crossterm, noreply.github.com 07:05:46 -0500
    8. with fix (#4684)
    9. 2 ece5e7db dataframe list Fernando Herrera fernando.j.herrera@g Tue, 1 Mar 2022
    10. command (#4681) mail.com 11:41:13 +0000
    11. 3 a6a96b29 Add binary literals JT 547158+jntrnr@users. Mon, 28 Feb 2022
    12. (#4680) noreply.github.com 18:31:53 -0500
    13. 4 e3100e6a Fix alias in Luca Trevisani lucatrv@hotmail.com Mon, 28 Feb 2022
    14. `docs/sample_config/ │ │ │ 22:47:14 +0100
    15. │ │ config.toml`
    16. (#4669)
    17. ───┴──────────┴──────────────────────┴──────────────────┴──────────────────────┴──────────────────

    Hmmm, that date string is a string. If it were a date vs a string it could be used for sorting by date. The way we do that is we have to convert the date time to a real datetime and update the column. Try this.

    1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 5 | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime}

    Now this looks more nu-ish

    1. ───┬──────────┬──────────────────────────┬──────────────────┬──────────────────────────┬──────────────
    2. # │ commit │ subject │ name │ email │ date
    3. ───┼──────────┼──────────────────────────┼──────────────────┼──────────────────────────┼──────────────
    4. 0 42f1874a Update some examples and Justin Ma hustcer@outlook.com 7 hours ago
    5. docs (#4682)
    6. 1 2a89936b Move to latest stable JT 547158+jntrnr@users.nore 8 hours ago
    7. crossterm, with fix ply.github.com
    8. (#4684)
    9. 2 ece5e7db dataframe list command Fernando Herrera fernando.j.herrera@gmail 8 hours ago
    10. (#4681) .com
    11. 3 a6a96b29 Add binary literals JT 547158+jntrnr@users.nore 20 hours ago
    12. (#4680) ply.github.com
    13. 4 e3100e6a Fix alias in Luca Trevisani lucatrv@hotmail.com a day ago
    14. `docs/sample_config/conf │ │ │
    15. │ │ ig.toml`
    16. (#4669)
    17. ───┴──────────┴──────────────────────────┴──────────────────┴──────────────────────────┴──────────────

    If we want to revert back to a date string we can do something like this with the nth command and the get command.

    1. Mon, 28 Feb 2022 18:31:53 -0500

    Cool! Now that we have a real datetime we can do some interesting things with it like group-by or sort-by or where. Let’s try sort-by first

    1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime} | sort-by date
    1. ────┬──────────┬──────────────────────────┬───────────────────┬─────────────────────────┬──────────────
    2. # │ commit │ subject │ name │ email │ date
    3. ────┼──────────┼──────────────────────────┼───────────────────┼─────────────────────────┼──────────────
    4. 0 0c3ea636 Add support for stderr JT 547158+jntrnr@users.nor 4 days ago
    5. and exit code (#4647) eply.github.com
    6. 1 ed46f0ea fix: add missing Jae-Heon Ji 32578710+jaeheonji@user 3 days ago
    7. metadata for `ls_colors` s.noreply.github.com
    8. (#4603)
    9. 2 3eca43c0 Plugins without file Fernando Herrera fernando.j.herrera@gmai 3 days ago
    10. (#4650) l.com
    11. 3 11bc0565 Find with regex flag Fernando Herrera fernando.j.herrera@gmai 3 days ago
    12. (#4649) l.com
    13. 4 d2bd71d2 add LAST_EXIT_CODE LordMZTE lord@mzte.de 3 days ago
    14. variable (#4655)
    15. 5 799fa984 Update reedline, revert Stefan Holderbach sholderbach@users.norep 3 days ago
    16. crossterm (#4657) ly.github.com
    17. 6 995757c0 flags for find (#4663) Fernando Herrera fernando.j.herrera@gmai 2 days ago
    18. l.com
    19. 7 446c2aab Lets internals also JT 547158+jntrnr@users.nor 2 days ago
    20. have exit codes (#4664) eply.github.com
    21. 8 10ceac99 menu keybindings in Fernando Herrera fernando.j.herrera@gmai 2 days ago
    22. default file (#4651) l.com
    23. 9 4ebbe07d Polars upgrade (#4665) Fernando Herrera fernando.j.herrera@gmai 2 days ago
    24. l.com
    25. 10 78192100 Add shortcircuiting JT 547158+jntrnr@users.nor 2 days ago
    26. boolean operators eply.github.com
    27. (#4668)
    28. 11 796d4920 add char separators Darren Schroeder 343840+fdncred@users.no 2 days ago
    29. (#4667) reply.github.com
    30. 12 0f437589 add last exit code to Darren Schroeder 343840+fdncred@users.no 2 days ago
    31. starship parameters reply.github.com
    32. (#4670)
    33. 13 ef70c8db Date parse refactor Jonathan Moore jtm170330@utdallas.edu 2 days ago
    34. (#4661)
    35. 14 10364c4f don't use table │ JT │ 547158+jntrnr@users.nor │ a day ago
    36. │ │ compaction in to nuon if │ │ eply.github.com │
    37. │ │ not a table (#4671) │ │ │
    38. 15 │ eec17304 │ Add profiling build │ Stefan Holderbach │ sholderbach@users.norep │ a day ago
    39. │ │ profile and symbol strip │ │ ly.github.com │
    40. │ │ (#4630) │ │ │
    41. 16 │ d6a6c4b0 │ Add back in default │ JT │ 547158+jntrnr@users.nor │ a day ago
    42. │ │ keybindings (#4673) │ │ eply.github.com │
    43. 17 │ 0924975b │ Use default_config.nu │ JT │ 547158+jntrnr@users.nor │ a day ago
    44. │ │ by default (#4675) │ │ eply.github.com │
    45. 18 │ b09acdb7 │ Fix unsupported type │ Justin Ma │ hustcer@outlook.com │ a day ago
    46. │ │ message for some math │ │ │
    47. │ │ related commands (#4672) │ │ │
    48. 19 │ cb5c61d2 │ Fix open ended ranges │ JT │ 547158+jntrnr@users.nor │ a day ago
    49. │ │ (#4677) │ │ eply.github.com │
    50. 20 │ e3100e6a │ Fix alias in │ Luca Trevisani │ lucatrv@hotmail.com │ a day ago
    51. │ │ `docs/sample_config/con │ │ │
    52. │ │ fig.toml` │ │ │
    53. │ │ (#4669) │ │ │
    54. 21 │ a6a96b29 │ Add binary literals │ JT │ 547158+jntrnr@users.nor │ 20 hours ago
    55. │ │ (#4680) │ │ eply.github.com │
    56. 22 │ ece5e7db │ dataframe list command │ Fernando Herrera │ fernando.j.herrera@gmai │ 8 hours ago
    57. │ │ (#4681) │ │ l.com │
    58. 23 │ 2a89936b │ Move to latest stable │ JT │ 547158+jntrnr@users.nor │ 8 hours ago
    59. │ │ crossterm, with fix │ │ eply.github.com │
    60. │ │ (#4684) │ │ │
    61. 24 │ 42f1874a │ Update some examples │ Justin Ma │ hustcer@outlook.com │ 7 hours ago
    62. │ │ and docs (#4682) │ │ │
    63. ────┴──────────┴──────────────────────────┴───────────────────┴─────────────────────────┴──────────────

    That’s neat but what if I want it sorted in the opposite order? Try the reverse command and notice the newest commits are at the top.

      1. ────┬──────────┬──────────────────────────┬───────────────────┬─────────────────────────┬──────────────
      2. # │ commit │ subject │ name │ email │ date
      3. ────┼──────────┼──────────────────────────┼───────────────────┼─────────────────────────┼──────────────
      4. 0 42f1874a Update some examples Justin Ma hustcer@outlook.com 7 hours ago
      5. and docs (#4682)
      6. 1 2a89936b Move to latest stable JT 547158+jntrnr@users.nor 8 hours ago
      7. crossterm, with fix eply.github.com
      8. (#4684)
      9. 2 ece5e7db dataframe list command Fernando Herrera fernando.j.herrera@gmai 8 hours ago
      10. (#4681) l.com
      11. 3 a6a96b29 Add binary literals JT 547158+jntrnr@users.nor 20 hours ago
      12. (#4680) eply.github.com
      13. 4 e3100e6a Fix alias in Luca Trevisani lucatrv@hotmail.com a day ago
      14. `docs/sample_config/con │ │ │
      15. │ │ fig.toml`
      16. (#4669)
      17. 5 cb5c61d2 Fix open ended ranges JT 547158+jntrnr@users.nor a day ago
      18. (#4677) eply.github.com
      19. 6 b09acdb7 Fix unsupported type Justin Ma hustcer@outlook.com a day ago
      20. message for some math
      21. related commands (#4672)
      22. 7 0924975b Use default_config.nu JT 547158+jntrnr@users.nor a day ago
      23. by default (#4675) eply.github.com
      24. 8 d6a6c4b0 Add back in default JT 547158+jntrnr@users.nor a day ago
      25. keybindings (#4673) eply.github.com
      26. 9 eec17304 Add profiling build Stefan Holderbach sholderbach@users.norep a day ago
      27. profile and symbol strip ly.github.com
      28. (#4630)
      29. 10 10364c4f don't use table │ JT │ 547158+jntrnr@users.nor │ a day ago
      30. │ │ compaction in to nuon if │ │ eply.github.com │
      31. │ │ not a table (#4671) │ │ │
      32. 11 │ ef70c8db │ Date parse refactor │ Jonathan Moore │ jtm170330@utdallas.edu │ 2 days ago
      33. │ │ (#4661) │ │ │
      34. 12 │ 0f437589 │ add last exit code to │ Darren Schroeder │ 343840+fdncred@users.no │ 2 days ago
      35. │ │ starship parameters │ │ reply.github.com │
      36. │ │ (#4670) │ │ │
      37. 13 │ 796d4920 │ add char separators │ Darren Schroeder │ 343840+fdncred@users.no │ 2 days ago
      38. │ │ (#4667) │ │ reply.github.com │
      39. 14 │ 78192100 │ Add shortcircuiting │ JT │ 547158+jntrnr@users.nor │ 2 days ago
      40. │ │ boolean operators │ │ eply.github.com │
      41. │ │ (#4668) │ │ │
      42. 15 │ 4ebbe07d │ Polars upgrade (#4665) │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      43. │ │ │ │ l.com │
      44. 16 │ 10ceac99 │ menu keybindings in │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      45. │ │ default file (#4651) │ │ l.com │
      46. 17 │ 446c2aab │ Lets internals also │ JT │ 547158+jntrnr@users.nor │ 2 days ago
      47. │ │ have exit codes (#4664) │ │ eply.github.com │
      48. 18 │ 995757c0 │ flags for find (#4663) │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      49. │ │ │ │ l.com │
      50. 19 │ 799fa984 │ Update reedline, revert │ Stefan Holderbach │ sholderbach@users.norep │ 3 days ago
      51. │ │ crossterm (#4657) │ │ ly.github.com │
      52. 20 │ d2bd71d2 │ add LAST_EXIT_CODE │ LordMZTE │ lord@mzte.de │ 3 days ago
      53. │ │ variable (#4655) │ │ │
      54. 21 │ 11bc0565 │ Find with regex flag │ Fernando Herrera │ fernando.j.herrera@gmai │ 3 days ago
      55. │ │ (#4649) │ │ l.com │
      56. 22 │ 3eca43c0 │ Plugins without file │ Fernando Herrera │ fernando.j.herrera@gmai │ 3 days ago
      57. │ │ (#4650) │ │ l.com │
      58. 23 │ ed46f0ea │ fix: add missing │ Jae-Heon Ji │ 32578710+jaeheonji@user │ 3 days ago
      59. │ │ metadata for `ls_colors` │ │ s.noreply.github.com │
      60. │ │ (#4603) │ │ │
      61. 24 │ 0c3ea636 │ Add support for stderr │ JT │ 547158+jntrnr@users.nor │ 4 days ago
      62. │ │ and exit code (#4647) │ │ eply.github.com │
      63. ────┴──────────┴──────────────────────────┴───────────────────┴─────────────────────────┴──────────────

      Now let’s try group-by and see what happens. This is a tiny bit tricky because dates are tricky. When you use group-by on dates you have to remember to use the group-by date subcommand so it’s group-by date date_column_name.

      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime | date format '%Y-%m-%d'} | group-by date
      1. ────────────┬────────────────
      2. 2022-03-01 [table 3 rows]
      3. 2022-02-28 [table 8 rows]
      4. 2022-02-27 [table 8 rows]
      5. 2022-02-26 [table 5 rows]
      6. 2022-02-25 [table 1 row]
      7. ────────────┴────────────────

      This would look better if we transpose the data and name the columns

      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime | date format '%Y-%m-%d'} | group-by date | transpose date count
      1. ───┬────────────┬────────────────
      2. # │ date │ count
      3. ───┼────────────┼────────────────
      4. 0 2022-03-01 [table 3 rows]
      5. 1 2022-02-28 [table 8 rows]
      6. 2 2022-02-27 [table 8 rows]
      7. 3 2022-02-26 [table 5 rows]
      8. 4 2022-02-25 [table 1 row]
      9. ───┴────────────┴────────────────
      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime} | where ($it.date > ((date now) - 365day))
      1. ────┬──────────┬──────────────────────────┬───────────────────┬─────────────────────────┬──────────────
      2. # │ commit │ subject │ name │ email │ date
      3. ────┼──────────┼──────────────────────────┼───────────────────┼─────────────────────────┼──────────────
      4. 0 42f1874a Update some examples Justin Ma hustcer@outlook.com 7 hours ago
      5. and docs (#4682)
      6. 1 2a89936b Move to latest stable JT 547158+jntrnr@users.nor 8 hours ago
      7. crossterm, with fix eply.github.com
      8. (#4684)
      9. 2 ece5e7db dataframe list command Fernando Herrera fernando.j.herrera@gmai 8 hours ago
      10. (#4681) l.com
      11. 3 a6a96b29 Add binary literals JT 547158+jntrnr@users.nor 21 hours ago
      12. (#4680) eply.github.com
      13. 4 e3100e6a Fix alias in Luca Trevisani lucatrv@hotmail.com a day ago
      14. `docs/sample_config/con │ │ │
      15. │ │ fig.toml`
      16. (#4669)
      17. 5 cb5c61d2 Fix open ended ranges JT 547158+jntrnr@users.nor a day ago
      18. (#4677) eply.github.com
      19. 6 b09acdb7 Fix unsupported type Justin Ma hustcer@outlook.com a day ago
      20. message for some math
      21. related commands (#4672)
      22. 7 0924975b Use default_config.nu JT 547158+jntrnr@users.nor a day ago
      23. by default (#4675) eply.github.com
      24. 8 d6a6c4b0 Add back in default JT 547158+jntrnr@users.nor a day ago
      25. keybindings (#4673) eply.github.com
      26. 9 eec17304 Add profiling build Stefan Holderbach sholderbach@users.norep a day ago
      27. profile and symbol strip ly.github.com
      28. (#4630)
      29. 10 10364c4f don't use table │ JT │ 547158+jntrnr@users.nor │ a day ago
      30. │ │ compaction in to nuon if │ │ eply.github.com │
      31. │ │ not a table (#4671) │ │ │
      32. 11 │ ef70c8db │ Date parse refactor │ Jonathan Moore │ jtm170330@utdallas.edu │ 2 days ago
      33. │ │ (#4661) │ │ │
      34. 12 │ 0f437589 │ add last exit code to │ Darren Schroeder │ 343840+fdncred@users.no │ 2 days ago
      35. │ │ starship parameters │ │ reply.github.com │
      36. │ │ (#4670) │ │ │
      37. 13 │ 796d4920 │ add char separators │ Darren Schroeder │ 343840+fdncred@users.no │ 2 days ago
      38. │ │ (#4667) │ │ reply.github.com │
      39. 14 │ 78192100 │ Add shortcircuiting │ JT │ 547158+jntrnr@users.nor │ 2 days ago
      40. │ │ boolean operators │ │ eply.github.com │
      41. │ │ (#4668) │ │ │
      42. 15 │ 4ebbe07d │ Polars upgrade (#4665) │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      43. │ │ │ │ l.com │
      44. 16 │ 10ceac99 │ menu keybindings in │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      45. │ │ default file (#4651) │ │ l.com │
      46. 17 │ 446c2aab │ Lets internals also │ JT │ 547158+jntrnr@users.nor │ 2 days ago
      47. │ │ have exit codes (#4664) │ │ eply.github.com │
      48. 18 │ 995757c0 │ flags for find (#4663) │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      49. │ │ │ │ l.com │
      50. 19 │ 799fa984 │ Update reedline, revert │ Stefan Holderbach │ sholderbach@users.norep │ 3 days ago
      51. │ │ crossterm (#4657) │ │ ly.github.com │
      52. 20 │ d2bd71d2 │ add LAST_EXIT_CODE │ LordMZTE │ lord@mzte.de │ 3 days ago
      53. │ │ variable (#4655) │ │ │
      54. 21 │ 11bc0565 │ Find with regex flag │ Fernando Herrera │ fernando.j.herrera@gmai │ 3 days ago
      55. │ │ (#4649) │ │ l.com │
      56. 22 │ 3eca43c0 │ Plugins without file │ Fernando Herrera │ fernando.j.herrera@gmai │ 3 days ago
      57. │ │ (#4650) │ │ l.com │
      58. 23 │ ed46f0ea │ fix: add missing │ Jae-Heon Ji │ 32578710+jaeheonji@user │ 3 days ago
      59. │ │ (#4603) │ │ │
      60. 24 │ 0c3ea636 │ Add support for stderr │ JT │ 547158+jntrnr@users.nor │ 4 days ago
      61. │ │ and exit code (#4647) │ │ eply.github.com │
      62. ────┴──────────┴──────────────────────────┴───────────────────┴─────────────────────────┴──────────────

      Or even show me all the commits in the last 7 days.

      1. ────┬──────────┬──────────────────────────┬───────────────────┬─────────────────────────┬──────────────
      2. # │ commit │ subject │ name │ email │ date
      3. ────┼──────────┼──────────────────────────┼───────────────────┼─────────────────────────┼──────────────
      4. 0 42f1874a Update some examples Justin Ma hustcer@outlook.com 7 hours ago
      5. and docs (#4682)
      6. 1 2a89936b Move to latest stable JT 547158+jntrnr@users.nor 8 hours ago
      7. crossterm, with fix eply.github.com
      8. (#4684)
      9. 2 ece5e7db dataframe list command Fernando Herrera fernando.j.herrera@gmai 8 hours ago
      10. (#4681) l.com
      11. 3 a6a96b29 Add binary literals JT 547158+jntrnr@users.nor 21 hours ago
      12. (#4680) eply.github.com
      13. 4 e3100e6a Fix alias in Luca Trevisani lucatrv@hotmail.com a day ago
      14. `docs/sample_config/con │ │ │
      15. │ │ fig.toml`
      16. (#4669)
      17. 5 cb5c61d2 Fix open ended ranges JT 547158+jntrnr@users.nor a day ago
      18. (#4677) eply.github.com
      19. 6 b09acdb7 Fix unsupported type Justin Ma hustcer@outlook.com a day ago
      20. message for some math
      21. related commands (#4672)
      22. 7 0924975b Use default_config.nu JT 547158+jntrnr@users.nor a day ago
      23. by default (#4675) eply.github.com
      24. 8 d6a6c4b0 Add back in default JT 547158+jntrnr@users.nor a day ago
      25. keybindings (#4673) eply.github.com
      26. 9 eec17304 Add profiling build Stefan Holderbach sholderbach@users.norep a day ago
      27. profile and symbol strip ly.github.com
      28. (#4630)
      29. 10 10364c4f don't use table │ JT │ 547158+jntrnr@users.nor │ a day ago
      30. │ │ compaction in to nuon if │ │ eply.github.com │
      31. │ │ not a table (#4671) │ │ │
      32. 11 │ ef70c8db │ Date parse refactor │ Jonathan Moore │ jtm170330@utdallas.edu │ 2 days ago
      33. │ │ (#4661) │ │ │
      34. 12 │ 0f437589 │ add last exit code to │ Darren Schroeder │ 343840+fdncred@users.no │ 2 days ago
      35. │ │ starship parameters │ │ reply.github.com │
      36. │ │ (#4670) │ │ │
      37. 13 │ 796d4920 │ add char separators │ Darren Schroeder │ 343840+fdncred@users.no │ 2 days ago
      38. │ │ (#4667) │ │ reply.github.com │
      39. 14 │ 78192100 │ Add shortcircuiting │ JT │ 547158+jntrnr@users.nor │ 2 days ago
      40. │ │ boolean operators │ │ eply.github.com │
      41. │ │ (#4668) │ │ │
      42. 15 │ 4ebbe07d │ Polars upgrade (#4665) │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      43. │ │ │ │ l.com │
      44. 16 │ 10ceac99 │ menu keybindings in │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      45. │ │ default file (#4651) │ │ l.com │
      46. 17 │ 446c2aab │ Lets internals also │ JT │ 547158+jntrnr@users.nor │ 2 days ago
      47. │ │ have exit codes (#4664) │ │ eply.github.com │
      48. 18 │ 995757c0 │ flags for find (#4663) │ Fernando Herrera │ fernando.j.herrera@gmai │ 2 days ago
      49. │ │ │ │ l.com │
      50. 19 │ 799fa984 │ Update reedline, revert │ Stefan Holderbach │ sholderbach@users.norep │ 3 days ago
      51. │ │ crossterm (#4657) │ │ ly.github.com │
      52. 20 │ d2bd71d2 │ add LAST_EXIT_CODE │ LordMZTE │ lord@mzte.de │ 3 days ago
      53. │ │ variable (#4655) │ │ │
      54. 21 │ 11bc0565 │ Find with regex flag │ Fernando Herrera │ fernando.j.herrera@gmai │ 3 days ago
      55. │ │ (#4649) │ │ l.com │
      56. 22 │ 3eca43c0 │ Plugins without file │ Fernando Herrera │ fernando.j.herrera@gmai │ 3 days ago
      57. │ │ (#4650) │ │ l.com │
      58. 23 │ ed46f0ea │ fix: add missing │ Jae-Heon Ji │ 32578710+jaeheonji@user │ 3 days ago
      59. │ │ metadata for `ls_colors` │ │ s.noreply.github.com │
      60. │ │ (#4603) │ │ │
      61. 24 │ 0c3ea636 │ Add support for stderr │ JT │ 547158+jntrnr@users.nor │ 4 days ago
      62. │ │ and exit code (#4647) │ │ eply.github.com │
      63. ────┴──────────┴──────────────────────────┴───────────────────┴─────────────────────────┴──────────────

      Now, with the 365 day slice of data, let’s group-by name where the commits are less than a year old. This table has a lot of columns so it’s unreadable. However, if we group-by name and transpose the table things will look much cleaner. Pivot takes rows and turns them into columns or turns columns into rows.

      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime} | where ($it.date > ((date now) - 365day)) | group-by name | transpose
      1. ─────┬─────────────────────────────────┬──────────────────
      2. # │ column0 │ column1
      3. ─────┼─────────────────────────────────┼──────────────────
      4. 0 Justin Ma [table 21 rows]
      5. 1 JT [table 851 rows]
      6. 2 Fernando Herrera [table 176 rows]
      7. 3 Luca Trevisani [table 1 row]
      8. 4 Stefan Holderbach [table 19 rows]
      9. 5 Jonathan Moore [table 2 rows]
      10. 6 Darren Schroeder [table 242 rows]
      11. 7 LordMZTE [table 1 row]
      12. 8 Jae-Heon Ji [table 10 rows]
      13. 9 zkldi [table 1 row]
      14. 10 Michael Angerman [table 61 rows]
      15. ...

      Side note: If you happen to get errors, pay attention to the error message. For instance, this error means that the data being returned from git log is somehow incomplete. Specifically, there is a missing date column. I’ve seen git commands work perfectly on Windows and not work at all on Linux or Mac. I’m not sure why. If you run into this issue, one easy way to temporarily avoid it is to limit git log results to a certain number like git log -n 100.

      1. error: Unknown column
      2. ┌─ shell:1:124
      3. 1 git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime} | where ($it.date > ((date now) - 365day))
      4. ^^^^
      5. There isn't a column named 'date'
      6. │ Perhaps you meant 'commit'? Columns available: commit, subject

      Here’s one tip for dealing with this error. We have a do command that has an --ignore_errors parameter. This is how you’d use it in the above example, if it were giving errors.

      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD | lines | do -i { split column "»¦«" commit subject name email date } | upsert date {|d| $d.date | into datetime} | where ($it.date > ((date now) - 365day)) | group-by name | transpose

      Now, back to parsing. What if we throw in the sort-by and reverse commands for good measure? Also, while we’re in there, let’s get rid of the [table 21 rows] thing too. We do that by using the length command on each row of column1.

      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime} | where ($it.date > ((date now) - 365day)) | group-by name | transpose | upsert column1 {|c| $c.column1 | length} | sort-by column1 | reverse
      1. ─────┬─────────────────────────────────┬─────────
      2. # │ column0 │ column1
      3. ─────┼─────────────────────────────────┼─────────
      4. 0 JT 851
      5. 1 Darren Schroeder 242
      6. 2 Fernando Herrera 176
      7. 3 Jakub Žádník 136
      8. 4 Michael Angerman 61
      9. 5 Andrés N. Robalino 29
      10. 6 Luccas Mateus 27
      11. 7 Stefan Stanciulescu 27
      12. 8 Jonathan Turner 23
      13. 9 Tanishq Kancharla 21
      14. 10 Justin Ma 21
      15. 11 onthebridgetonowhere 20
      16. 12 xiuxiu62 19
      17. ...

      This is still a lot of data so let’s just look at the top 10 and use the rename command to name the columns. We could’ve also provided the column names with the transpose command.

      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime} | group-by name | transpose | upsert column1 {|c| $c.column1 | length} | sort-by column1 | rename name commits | reverse | first 10
      1. ───┬────────────────────┬─────────
      2. # │ name │ commits
      3. ───┼────────────────────┼─────────
      4. 0 Jonathan Turner 1420
      5. 1 JT 851
      6. 2 Andrés N. Robalino 383
      7. 3 Darren Schroeder 380
      8. 4 Fernando Herrera 176
      9. 5 Yehuda Katz 165
      10. 6 Jakub Žádník 140
      11. 7 Joseph T. Lyons 87
      12. 8 Michael Angerman 71
      13. 9 Jason Gedge 67
      14. ───┴────────────────────┴─────────

      And there you have it. The top 10 committers and we learned a little bit of parsing along the way.

      Here’s one last little known command. Perhaps you don’t want your table numbered starting with 0. Here’s a way to change that with the table command.

      1. > git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD | lines | split column "»¦«" commit subject name email date | upsert date {|d| $d.date | into datetime} | group-by name | transpose | upsert column1 {|c| $c.column1 | length} | sort-by column1 | rename name commits | reverse | first 10 | table -n 1
      1. ────┬────────────────────┬─────────
      2. # │ name │ commits
      3. ────┼────────────────────┼─────────
      4. 1 Jonathan Turner 1420
      5. 2 JT 851
      6. 3 Andrés N. Robalino 383
      7. 4 Darren Schroeder 380
      8. 5 Fernando Herrera 176
      9. 6 Yehuda Katz 165
      10. 7 Jakub Žádník 140
      11. 8 Joseph T. Lyons 87
      12. 9 Michael Angerman 71