Onefetch is a command line tool that displays information about your Git repository directly on your terminal. Onefetch supports almost 50 different programming languages. If your language of choice isn't supported: Open up an issue and support will be added.
Git repository summary on your terminal
Onefetch is a command line tool that displays information about your Git repository directly on your terminal. Onefetch supports almost 50 different programming languages. If your language of choice isn't supported: Open up an iCategory: Linux / Miscellaneous |
Watchers: 29 |
Star: 5.2k |
Fork: 188 |
Last update: May 18, 2022 |
When trying to use onefetch from snap its fails with Error: please run onefetch inside of a non-bare git repository
$ onefetch --help
onefetch 2.11.0
When using version from apt everything works
$ onefetch --help
onefetch 2.10.2
My system:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.10
Release: 21.10
Codename: impish
If I open a split terminal in say VSCode, onefetch (obviously) gets really deformed
We can use the term_size crate to get terminal size, and from there, omit either the ASCII logo or the insignts.
The question then becomes which one we should remove. I'm thinking logo, but I want to know what you think.
- [ ] Prevent line wrap by default with
print!("\x1B[?7l")
- I'll take care of that one. - [x] Add options to the -off CLI flag (rename it to --hide-logo) to automatically hide the art if the term_size is too small.
The logo is just like the C logo but with a cross, and with TempleOS colors
This is a very first preview of what it would mean to use gitoxide for commit-traversal alone, done with the smallest possible changes for everything to remain as familiar as possible. It ain't super pretty yet, but it will get there. My rough plan is to get feedback early and ultimately squash all/most commits once a merge is possible.
Furthermore I think a delayed progress bar could easily be implemented to provide some entertainment while people are waiting for their huge repositories (those will never finish below 1s no matter how hard we try 😅).
Right now it's 2.2x faster on reactos and 2.4x faster on the linux kernel at 4% the heap memory consumption compared to what's on main
.
I am looking forward to your feedback.
Making-of Video
- A video highlighting a few improvements done to
gitoxide
to make this PR possible.
Additional Changes
- [x] #636
- [x] Call worktree change detection in separate thread, see this comment for a reasoning
- [x] #629
- [x] add support for object replacement (see #592)
Tasks
- [x]
git-mailmap
- [x] initial use of
gitoxide
for commit graph traversal - [x] avoid allocating all commits and avoid string-duplication in
Sig
- [x] Use
gitoxide
in all possible places to validate the API is en-par withgit2
or more convenient- configuration access and worktree-status is still done by
git2
, but we are working on it, this should be ready this year.
- configuration access and worktree-status is still done by
- [x] basic parallelization
- …what about progress ❓
- [x] release
gitoxide
and switch to usingcrates.io
Performance
-
e3b29b0aee7391baa39f613aa8798b0c137e386a - commit traversal with
gitoxide
- reactos - 1.492 s → 1.040 s = 1.43x
- linux v5.16 - 19.634 s → 10.886 s = 1.80x, 1.47 GB → 1.18 GB peak mem = 0.8x
-
0652bbeb488c51243aa3a2283dc0bc6994a4f37b - minimize allocations
- reactos - 986.2 ms → 915.4 ms = 1.08x
- linux v5.15 - 11.313 s → 9.670 s = 1.17x, 1180 MB → 62 MB peak mem = 0.05x
-
633f0ce6cad0a664e764627b3f193aa59eb212a6 - parallelize workspace status, tokei, and commit traversal
- reactos - 915.4 ms → 703.7 ms = 1.30x
- linux v5.15 - 9.670 s → 8.070 s = 1.20x
Performance comparison with main
- reactos - 1.492 s → 703.7 ms = 2.12x
- linux v5.15 - 19.634 s → 8.070 s = 2.43x, 1470 MB → 62 MB peak mem = 0.04x
On 633f0ce6cad0a664e764627b3f193aa59eb212a6
reactos
➜ reactos git:(master) hyperfine ~/dev/github.com/o2sh/onefetch/target/release/onefetch
Benchmark 1: /Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch
Time (mean ± σ): 703.7 ms ± 54.6 ms [User: 2148.3 ms, System: 526.4 ms]
Range (min … max): 605.4 ms … 814.1 ms 10 runs
linux v5.16
➜ linux git:(df0cc57e057f) ✗ hyperfine ~/dev/github.com/o2sh/onefetch/target/release/onefetch
Benchmark 1: /Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch
Time (mean ± σ): 8.070 s ± 0.139 s [User: 12.196 s, System: 1.909 s]
Range (min … max): 7.900 s … 8.314 s 10 runs
On 0652bbeb488c51243aa3a2283dc0bc6994a4f37b
reactos
➜ reactos git:(master) hyperfine onefetch ~/dev/github.com/o2sh/onefetch/target/release/onefetch
Benchmark 1: onefetch
Time (mean ± σ): 986.2 ms ± 9.9 ms [User: 2120.3 ms, System: 618.4 ms]
Range (min … max): 976.1 ms … 1003.5 ms 10 runs
Benchmark 2: /Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch
Time (mean ± σ): 915.4 ms ± 19.5 ms [User: 2062.3 ms, System: 578.8 ms]
Range (min … max): 902.2 ms … 966.8 ms 10 runs
Summary
'/Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch' ran
1.08 ± 0.03 times faster than 'onefetch'
** linux**
➜ linux git:(df0cc57e057f) ✗ hyperfine onefetch ~/dev/github.com/o2sh/onefetch/target/release/onefetch
Benchmark 1: onefetch
Time (mean ± σ): 11.313 s ± 0.193 s [User: 13.065 s, System: 2.030 s]
Range (min … max): 10.997 s … 11.572 s 10 runs
Benchmark 2: /Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch
Time (mean ± σ): 9.670 s ± 0.118 s [User: 12.319 s, System: 1.782 s]
Range (min … max): 9.482 s … 9.835 s 10 runs
Summary
'/Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch' ran
1.17 ± 0.02 times faster than 'onefetch'
➜ linux git:(df0cc57e057f) ✗ /usr/bin/time -lp /Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch
++++++ Sebastian Thiel ~ git version 2.32.0 (Apple Git-132)
++++++++++++ ----------------------------------------------------
++++++++++++++++++++ Project: linux (1 branch, 735 tags)
++++++++++++++++++++++++++ HEAD: df0cc57 (linux-checkout-4)
++++++++++++++++++++++++++++++++ Pending: 13+- 13-
+++++++++++++************+++++++++++++ Version: v5.17-rc7
+++++++++++******************++++++++;;; Created: 7 years ago
+++++++++**********************++;;;;;;; Languages:
++++++++*********++++++******;;;;;;;;;;; ● C (99.0 %) ● Shell (0.5 %)
+++++++********++++++++++**;;;;;;;;;;;;; ● Python (0.2 %) ● Perl (0.2 %)
+++++++*******+++++++++;;;;;;;;;;;;;;;;; ● Assembly (0.0 %) ● C++ (0.0 %)
+++++++******+++++++;;;;;;;;;;;;;;;;;;;; ● Other (0.0 %)
+++++++*******+++:::::;;;;;;;;;;;;;;;;;; Authors: 3% Linus Torvalds 30365
+++++++********::::::::::**;;;;;;;;;;;;; 1% David S. Miller 13285
++++++++*********::::::******;;;;;;;;;;; 1% Arnd Bergmann 8636
++++++:::**********************::;;;;;;; Last change: 2 months ago
+++::::::::******************::::::::;;; Contributors: 31713
:::::::::::::************::::::::::::: Repo: https://github.com/torvalds/linux
:::::::::::::::::::::::::::::::: Commits: 1060298
:::::::::::::::::::::::::: Lines of code: 16026142
:::::::::::::::::::: Size: 1.02 GiB (74304 files)
::::::::::::
::::::
real 9.51
user 12.18
sys 2.00
868958208 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
73721 page reclaims
1 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
6 voluntary context switches
23996 involuntary context switches
113921189621 instructions retired
43680206129 cycles elapsed
62381056 peak memory footprint
➜ linux git:(df0cc57e057f) ✗ /usr/bin/time -lp onefetch
++++++ Sebastian Thiel ~ git version 2.32.0 (Apple Git-132)
++++++++++++ ----------------------------------------------------
++++++++++++++++++++ Project: linux (1 branch, 735 tags)
++++++++++++++++++++++++++ HEAD: df0cc57 (linux-checkout-4)
++++++++++++++++++++++++++++++++ Pending: 13+- 13-
+++++++++++++************+++++++++++++ Version: v5.17-rc7
+++++++++++******************++++++++;;; Created: 7 years ago
+++++++++**********************++;;;;;;; Languages:
++++++++*********++++++******;;;;;;;;;;; ● C (99.0 %) ● Shell (0.5 %)
+++++++********++++++++++**;;;;;;;;;;;;; ● Python (0.2 %) ● Perl (0.2 %)
+++++++*******+++++++++;;;;;;;;;;;;;;;;; ● Assembly (0.0 %) ● C++ (0.0 %)
+++++++******+++++++;;;;;;;;;;;;;;;;;;;; ● Other (0.0 %)
+++++++*******+++:::::;;;;;;;;;;;;;;;;;; Authors: 3% Linus Torvalds 30365
+++++++********::::::::::**;;;;;;;;;;;;; 1% David S. Miller 13285
++++++++*********::::::******;;;;;;;;;;; 1% Arnd Bergmann 8636
++++++:::**********************::;;;;;;; Last change: 2 months ago
+++::::::::******************::::::::;;; Contributors: 31712
:::::::::::::************::::::::::::: Repo: https://github.com/torvalds/linux
:::::::::::::::::::::::::::::::: Commits: 1060298
:::::::::::::::::::::::::: Lines of code: 16026142
:::::::::::::::::::: Size: 1.02 GiB (74304 files)
::::::::::::
::::::
real 11.42
user 12.88
sys 2.17
2300035072 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
140632 page reclaims
638 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
45086 voluntary context switches
47751 involuntary context switches
125092258058 instructions retired
47152882263 cycles elapsed
1178364992 peak memory footprint
On e3b29b0aee7391baa39f613aa8798b0c137e386a
reactos
➜ reactos git:(master) hyperfine onefetch ~/dev/github.com/o2sh/onefetch/target/release/onefetch
Benchmark 1: onefetch
Time (mean ± σ): 1.492 s ± 0.084 s [User: 2.549 s, System: 0.698 s]
Range (min … max): 1.437 s … 1.726 s 10 runs
Benchmark 2: /Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch
Time (mean ± σ): 1.040 s ± 0.130 s [User: 2.158 s, System: 0.609 s]
Range (min … max): 0.989 s … 1.408 s 10 runs
Warning: The first benchmarking run for this command was significantly slower than the rest (1.408 s). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.
Summary
'/Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch' ran
1.43 ± 0.20 times faster than 'onefetch'
linux v5.16
➜ linux git:(df0cc57e057f) ✗ hyperfine onefetch ~/dev/github.com/o2sh/onefetch/target/release/onefetch
Benchmark 1: onefetch
Time (mean ± σ): 19.634 s ± 1.127 s [User: 20.267 s, System: 2.932 s]
Range (min … max): 18.966 s … 22.787 s 10 runs
Warning: The first benchmarking run for this command was significantly slower than the rest (22.787 s). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.
Benchmark 2: /Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch
Time (mean ± σ): 10.886 s ± 0.416 s [User: 13.057 s, System: 2.024 s]
Range (min … max): 10.351 s … 11.571 s 10 runs
Summary
'/Users/byron/dev/github.com/o2sh/onefetch/target/release/onefetch' ran
1.80 ± 0.12 times faster than 'onefetch'
It also uses less memory (already)
➜ linux git:(df0cc57e057f) ✗ /usr/bin/time -lp onefetch
/usr/bin/time -lp ~/dev/github.com/o2sh/onefetch/target/release/onefetch
++++++ Sebastian Thiel ~ git version 2.32.0 (Apple Git-132)
++++++++++++ ----------------------------------------------------
++++++++++++++++++++ Project: linux (1 branch, 735 tags)
++++++++++++++++++++++++++ HEAD: df0cc57 (linux-checkout-4)
++++++++++++++++++++++++++++++++ Pending: 13+- 13-
+++++++++++++************+++++++++++++ Version: v5.17-rc7
+++++++++++******************++++++++;;; Created: 16 years ago
+++++++++**********************++;;;;;;; Languages:
++++++++*********++++++******;;;;;;;;;;; ● C (99.0 %) ● Shell (0.5 %)
+++++++********++++++++++**;;;;;;;;;;;;; ● Python (0.2 %) ● Perl (0.2 %)
+++++++*******+++++++++;;;;;;;;;;;;;;;;; ● Assembly (0.0 %) ● C++ (0.0 %)
+++++++******+++++++;;;;;;;;;;;;;;;;;;;; ● Other (0.0 %)
+++++++*******+++:::::;;;;;;;;;;;;;;;;;; Authors: 3% Linus Torvalds 30365
+++++++********::::::::::**;;;;;;;;;;;;; 1% David S. Miller 13285
++++++++*********::::::******;;;;;;;;;;; 1% Arnd Bergmann 8636
++++++:::**********************::;;;;;;; Last change: 2 months ago
+++::::::::******************::::::::;;; Contributors: 31710
:::::::::::::************::::::::::::: Repo: https://github.com/torvalds/linux
:::::::::::::::::::::::::::::::: Commits: 1060298
:::::::::::::::::::::::::: Lines of code: 16026142
:::::::::::::::::::: Size: 1.02 GiB (74304 files)
::::::::::::
::::::
real 19.71
user 20.29
sys 3.22
2462187520 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
197675 page reclaims
0 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
45187 voluntary context switches
50938 involuntary context switches
235305804597 instructions retired
74307371842 cycles elapsed
1579909760 peak memory footprint
➜ linux git:(df0cc57e057f) ✗ /usr/bin/time -lp ~/dev/github.com/o2sh/onefetch/target/release/onefetch
++++++ Sebastian Thiel ~ git version 2.32.0 (Apple Git-132)
++++++++++++ ----------------------------------------------------
++++++++++++++++++++ Project: linux (1 branch, 735 tags)
++++++++++++++++++++++++++ HEAD: df0cc57 (linux-checkout-4)
++++++++++++++++++++++++++++++++ Pending: 13+- 13-
+++++++++++++************+++++++++++++ Version: v5.17-rc7
+++++++++++******************++++++++;;; Created: 7 years ago
+++++++++**********************++;;;;;;; Languages:
++++++++*********++++++******;;;;;;;;;;; ● C (99.0 %) ● Shell (0.5 %)
+++++++********++++++++++**;;;;;;;;;;;;; ● Python (0.2 %) ● Perl (0.2 %)
+++++++*******+++++++++;;;;;;;;;;;;;;;;; ● Assembly (0.0 %) ● C++ (0.0 %)
+++++++******+++++++;;;;;;;;;;;;;;;;;;;; ● Other (0.0 %)
+++++++*******+++:::::;;;;;;;;;;;;;;;;;; Authors: 3% Linus Torvalds 30365
+++++++********::::::::::**;;;;;;;;;;;;; 1% David S. Miller 13285
++++++++*********::::::******;;;;;;;;;;; 1% Arnd Bergmann 8636
++++++:::**********************::;;;;;;; Last change: 2 months ago
+++::::::::******************::::::::;;; Contributors: 31712
:::::::::::::************::::::::::::: Repo: https://github.com/torvalds/linux
:::::::::::::::::::::::::::::::: Commits: 1060298
:::::::::::::::::::::::::: Lines of code: 16026142
:::::::::::::::::::: Size: 1.02 GiB (74304 files)
::::::::::::
::::::
real 11.07
user 13.31
sys 2.00
2298560512 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
140884 page reclaims
308 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
14833 voluntary context switches
24536 involuntary context switches
123147113212 instructions retired
47528928511 cycles elapsed
1181969472 peak memory footprint
Note that the contributor count is off by 2 - it's likely to be related to the mailmap, and for I don't know if libgit2
is off or gitoxide
. I will look into it.
closes #419
- [x] Cloning remote repository from HTTP URL
- [x] Caching repositories
- [x] Progress bars(git clone may take some time)
- [x] ~~Improve performance by fetching with depth = 1~~ I can't find option in git2 library
This is what it looks like on rust-analyzer
.
[1;37mProject: [0mrust-analyzer
[37m ` :y.`yy`.y: `[0m [1;37mHEAD: [0m0cce2bc (master, origin/master, origin/staging)
[37m -``MNsNMMNNNNMMNsNM``-[0m [1;37mVersion: [0mguide-2019-01
[37m ` -MMNMMMMNNm``NNNMMMMNMM- `[0m [1;37mCreated: [0m1 year, 10 months ago
[37m `NNNMMMdo:` `+md/ `:odMMMNNN`[0m [1;37mLanguages: [0mRust (96.38 %) TypeScript (3.57 %) JavaScript (0.04 %)
[37m -ssNMMNo. .oNMMNss-[0m Shell (0.01 %)
[37m `mMM[0m[91mMMNmmmmmmmmmmmmmmmdy+`[0m[37m `sMMMm`[0m [1;37mAuthors: [0m40% Aleksey Kladov 2128
[37m `mMMM[0m[91mMMMMMMMMMMMMMMMMMMMMMMN/[0m[37m hMMMMm`[0m [1;37m [0m25% bors[bot] 1313
[37m -oMN-:Ny:[0m[91mmMMMMMm oNMMMMMm[0m[37m oN::MMo-[0m [1;37m [0m5% Florian Diebold 296
[37m.yMMMhhh+ [0m[91mdMMMMMd:::::+mMMMMN/[0m[37m odyhMMMy.[0m [1;37mLast change: [0m4 hours ago
[37m-sNMMy [0m[91mdMMMMMMMMMMMMMMMMs`[0m[37m `yMMNs-[0m [1;37mRepo: [0mhttps://github.com/rust-analyzer/rust-analyzer.git
[37m-sNMMy [0m[91mdMMMMMNyyyydMMMMMMy[0m[37m .odMMNs-[0m [1;37mCommits: [0m5227
[37m.yMMMm [0m[91mdMMMMMh +MMMMMM+[0m[37m sMMMMMy.[0m [1;37mLines of code: [0m61872
[37m -oMMM[0m[91mMMMMMMMMMMMMMM+ mMMMMMMMMMM[0m[37mMMMo-[0m [1;37mSize: [0m18.96 MiB (889 files)
[37m `mMMM[0m[91mMMMMMMMMMMMMMM+ :NMMMMMMMMM[0m[37mMMMm`[0m [1;37mLicense: [0mApache License 2.0
[37m `mMMMm `-:o+:/mMMMm`[0m
[37m -ssNMMMyomo smohMMMNss-[0m
[37m `NNNMs+mN/-` `-/Nd/yMNNN`[0m
[37m ` -MMNMMMMMNmmmmNMMMMMNMM- `[0m
[37m -``MNsNMMNMMNMMNsNM``-[0m
[37m ` :y.`yy`.y: `[0m
This pull request adds a workflow that automatically publishes Onefetch to WinGet every release, as discussed in #638. Please do not merge this pull request without reading the below and making the required changes (The token part is the important bit) :)
runs-on: windows-latest
The WinGet Releaser action can only run on Windows.
identifier: o2sh.onefetch
This is the identifier for Onefetch on Winget. It will use this to find Onefetch's current package on WinGet.
installers-regex: '\.exe$'
This will make all .exe
files in the assets of the latest Onefetch release to be included in the pull request.
delete-previous-version: 'true'
This is optional, and you are welcome to change this to false (or omit it; the default is false). This will essentially overwrite the previous version on WinGet packages, so that only this new version is stored on WinGet. Again, entirely optional.
token: ${{ secrets.WINGET_TOKEN }}
This is the bit that will require action from yourself. This is a GitHub token with which the action will authenticate with GitHub and create a pull request on the winget-pkgs repository.
To do this, you will need to:
-
Create a Personal Access Token (PAT) with
public_repo
scope on your GitHub account. -
Create a repository secret containing the token. Super important: call this token:
WINGET_TOKEN
. See using encrypted secrets in a workflow for more details.
Finally, make sure you have a fork of winget-pkgs on your GitHub account. Please do not delete the fork after a pull request has been merged as the action will use that fork for making a branch and merging it with the upstream winget-pkgs repository on every Onefetch release.
The above is made on the assumption that the account that the token is from (and the fork is present) is @o2sh. If you would like this to be done by another account, the token would have to be from the different user and an extra line would have to be added: fork-user: # Username of other user
(this defaults to the repository owner, which is why it doesn't have to be added)
If you would like to read about this action further, the documentation is here and the source code is here.
If you are interested in what a pull request made by this action looks like, here is one from my account: #61982 on winget-pkgs.
If you are concerned about the generated executable (#668) not getting included in the action when it checks the assets, it actually has a retry logic that will retry for up to an hour, checking every ten minutes for the required asset in the created release. If it's still not in the assets at that point, it will fail and you can re-run it at a later date when it is.
It would be nice if this could be installed via WinGet
Following #621, we wish to run get_language_statistics() in parallel.
Following #621, we wish to drop libgit2 and use gitoxide instead.
This program is very slow when running it on large repositories, for example ReactOS.
i'm adding it to my repo.
make DESTDIR="/home/aureai/xir/image" install -j8
doesn't work. how can i fix it?