Home Explore Blog CI



nushell

6th chunk of `cookbook/parsing_git_log.md`
a6d4841a2efc7836a4b271223d24f398b77bc77f4ea58d5d0000000100001379
# =>     │          │ (#4681)                  │                   │ l.com                     │
# =>  23 │ 2a89936b │ Move to latest stable    │ Sophia            │ 547158+sophiajt@users.nor │ 8 hours ago
# =>     │          │ crossterm, with fix      │                   │ eply.github.com           │
# =>     │          │ (#4684)                  │                   │                           │
# =>  24 │ 42f1874a │ Update some examples     │ Justin Ma         │ hustcer@outlook.com       │ 7 hours ago
# =>     │          │ and docs (#4682)         │                   │                           │
# => ────┴──────────┴──────────────────────────┴───────────────────┴───────────────────────────┴──────────────
```

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.

```nu
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 | reverse
# => ────┬──────────┬──────────────────────────┬───────────────────┬───────────────────────────┬──────────────
# =>  #  │  commit  │         subject          │       name        │          email            │     date
# => ────┼──────────┼──────────────────────────┼───────────────────┼───────────────────────────┼──────────────
# =>   0 │ 42f1874a │ Update some examples     │ Justin Ma         │ hustcer@outlook.com       │ 7 hours ago
# =>     │          │ and docs (#4682)         │                   │                           │
# =>   1 │ 2a89936b │ Move to latest stable    │ Sophia            │ 547158+sophiajt@users.nor │ 8 hours ago
# =>     │          │ crossterm, with fix      │                   │ eply.github.com           │
# =>     │          │ (#4684)                  │                   │                           │
# =>   2 │ ece5e7db │ dataframe list command   │ Fernando Herrera  │ fernando.j.herrera@gmai   │ 8 hours ago
# =>     │          │ (#4681)                  │                   │ l.com                     │
# =>   3 │ a6a96b29 │ Add binary literals      │ Sophia            │ 547158+sophiajt@users.nor │ 20 hours ago
# =>     │          │ (#4680)                  │                   │ eply.github.com           │
# =>   4 │ e3100e6a │ Fix alias in             │ Luca Trevisani    │ lucatrv@hotmail.com       │ a day ago
# =>     │          │ `docs/sample_config/con  │                   │                           │
# =>     │          │ fig.toml`                │                   │                           │
# =>     │          │ (#4669)                  │                   │                           │
# =>   5 │ cb5c61d2 │ Fix open ended ranges    │ Sophia            │ 547158+sophiajt@users.nor │ a day ago
# =>     │          │ (#4677)                  │                   │ eply.github.com           │
# =>   6 │ b09acdb7 │ Fix unsupported type     │ Justin Ma         │ hustcer@outlook.com       │ a day ago
# =>     │          │ message for some math    │                   │                           │
# =>     │          │ related commands (#4672) │                   │                           │
# =>   7 │ 0924975b │ Use default_config.nu    │ Sophia            │ 547158+sophiajt@users.nor │ a day ago
# =>     │          │ by default (#4675)       │                   │ eply.github.com         │
# =>   8 │ d6a6c4b0 │ Add back in default      │ Sophia                │ 547158+sophiajt@users.nor │ a day ago
# =>     │          │ keybindings (#4673)      │                   │ eply.github.com         │
# =>   9 │ eec17304 │ Add profiling build      │ Stefan Holderbach │ sholderbach@users.norep │ a day ago
# =>     │          │ profile and symbol strip │                   │ ly.github.com           │
# =>     │          │ (#4630)                  │                   │                         │
# =>  10 │ 10364c4f │ don't use table          │ Sophia                │ 547158+sophiajt@users.nor │ a day ago

Title: Reversing Sorted Git Log Output in Nushell
Summary
This snippet demonstrates how to reverse the order of the sorted git log entries using Nushell. It takes the output from a git log command, splits it into columns, converts the date, sorts by date, and then reverses the order so the newest commits are displayed first.