Skip to content

Commit c2bb194

Browse files
authored
Merge branch 'main' into main
2 parents d3f5ef4 + 5aab919 commit c2bb194

File tree

9 files changed

+233
-28
lines changed

9 files changed

+233
-28
lines changed

.github/workflows/update-aur.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Update AUR Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
update-aur:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout main repo
13+
uses: actions/checkout@v4
14+
with:
15+
repository: Matars/gitfetch
16+
path: gitfetch
17+
18+
- name: Get version from pyproject.toml
19+
id: get_version
20+
run: |
21+
VERSION=$(grep '^version =' gitfetch/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
22+
echo "version=$VERSION" >> $GITHUB_OUTPUT
23+
24+
- name: Download release tarball
25+
run: |
26+
curl -L -o release.tar.gz https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz
27+
28+
- name: Calculate SHA256
29+
id: sha256
30+
run: |
31+
SHA256=$(shasum -a 256 release.tar.gz | cut -d' ' -f1)
32+
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
33+
34+
- name: Setup SSH
35+
run: |
36+
mkdir -p ~/.ssh
37+
echo "${{ secrets.AUR_TOKEN }}" > ~/.ssh/aur_key
38+
chmod 600 ~/.ssh/aur_key
39+
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts
40+
41+
- name: Clone AUR repo
42+
run: |
43+
git clone ssh://aur@aur.archlinux.org/gitfetch-python.git aur-repo
44+
cd aur-repo
45+
git config user.name "GitHub Actions"
46+
git config user.email "actions@github.com"
47+
48+
- name: Update PKGBUILD
49+
run: |
50+
cd aur-repo
51+
sed -i 's/pkgver=.*/pkgver=${{ steps.get_version.outputs.version }}/' PKGBUILD
52+
sed -i 's|source=.*|source=("$pkgname-$pkgver.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v$pkgver.tar.gz")|' PKGBUILD
53+
sed -i "s/sha256sums=.*/sha256sums=('${{ steps.sha256.outputs.sha256 }}')/" PKGBUILD
54+
55+
- name: Update .SRCINFO
56+
run: |
57+
cd aur-repo
58+
sed -i 's/pkgver = .*/pkgver = ${{ steps.get_version.outputs.version }}/' .SRCINFO
59+
sed -i 's|source = .*|source = gitfetch-python-${{ steps.get_version.outputs.version }}.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz|' .SRCINFO
60+
sed -i "s/sha256sums = .*/sha256sums = ${{ steps.sha256.outputs.sha256 }}/" .SRCINFO
61+
62+
- name: Commit and push
63+
run: |
64+
cd aur-repo
65+
git add PKGBUILD .SRCINFO
66+
git commit -m "Update gitfetch-python to v${{ steps.get_version.outputs.version }}"
67+
GIT_SSH_COMMAND="ssh -i ~/.ssh/aur_key -o UserKnownHostsFile=~/.ssh/known_hosts" git push
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Update Homebrew Formula
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
update-homebrew:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout main repo
13+
uses: actions/checkout@v4
14+
with:
15+
repository: Matars/gitfetch
16+
path: gitfetch
17+
18+
- name: Get version from pyproject.toml
19+
id: get_version
20+
run: |
21+
VERSION=$(grep '^version =' gitfetch/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
22+
echo "version=$VERSION" >> $GITHUB_OUTPUT
23+
24+
- name: Download release tarball
25+
run: |
26+
curl -L -o release.tar.gz https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz
27+
28+
- name: Calculate SHA256
29+
id: sha256
30+
run: |
31+
SHA256=$(shasum -a 256 release.tar.gz | cut -d' ' -f1)
32+
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
33+
34+
- name: Checkout tap repo
35+
uses: actions/checkout@v4
36+
with:
37+
repository: Matars/homebrew-gitfetch
38+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
39+
path: homebrew-tap
40+
41+
- name: Update formula
42+
run: |
43+
sed -i 's|url "https://github.com/Matars/gitfetch/archive/refs/tags/v.*"|url "https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz"|' homebrew-tap/Formula/gitfetch.rb
44+
sed -i 's|version ".*"|version "${{ steps.get_version.outputs.version }}"|' homebrew-tap/Formula/gitfetch.rb
45+
sed -i 's|sha256 ".*"|sha256 "${{ steps.sha256.outputs.sha256 }}"|' homebrew-tap/Formula/gitfetch.rb
46+
47+
- name: Commit and push
48+
run: |
49+
cd homebrew-tap
50+
git config user.name "GitHub Actions"
51+
git config user.email "actions@github.com"
52+
git add Formula/gitfetch.rb
53+
git commit -m "Update gitfetch to v${{ steps.get_version.outputs.version }}"
54+
git push

README.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# gitfetch
1+
tap# gitfetch
2+
3+
A neofetch-style CLI tool for GitHub statistics. Display your GitHub profile and stats in a beautiful, colorful terminal interface.
24

35
<img width="3024" height="1964" alt="image" src="https://github.com/user-attachments/assets/bbb18d5d-4787-4998-a352-e8f4e59642c0" />
46

5-
A neofetch-style CLI tool for GitHub statistics. Display your GitHub profile and stats in a beautiful, colorful terminal interface.
7+
<img width="3441" height="1441" alt="2025-10-20-143110_hyprshot" src="https://github.com/user-attachments/assets/ee31ebe3-257f-4aff-994e-fffd47b48fa1" />
68

79
## Features
810

@@ -45,11 +47,51 @@ You should see: `✓ Logged in to github.com as YOUR_USERNAME`
4547

4648
## Installing `gitfetch`
4749

50+
### macOS (Homebrew)
51+
52+
```bash
53+
brew install matars/gitfetch/gitfetch
54+
```
55+
56+
### Arch Linux (AUR)
57+
58+
```bash
59+
yay -S gitfetch
60+
```
61+
62+
Or with other AUR helpers:
63+
64+
```bash
65+
paru -S gitfetch
66+
trizen -S gitfetch
67+
```
68+
69+
Or manual build:
70+
71+
```bash
72+
git clone https://aur.archlinux.org/gitfetch.git
73+
cd gitfetch
74+
makepkg -si
75+
```
76+
77+
### From the sources
4878

4979
1. Clone this repo
5080
2. `cd` into the repo
5181
3. Then type the below command
5282

83+
### With `uv`
84+
85+
```bash
86+
uv tool install git+https://github.com/Matars/gitfetch
87+
```
88+
89+
### With `pipx`
90+
91+
```bash
92+
pipx install git+https://github.com/Matars/gitfetch
93+
```
94+
5395
```bash
5496
pip install -e .
5597
```

pyproject.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "gitfetch"
7-
version = "1.0.2"
7+
version = "1.0.13"
88
description = "A neofetch-style CLI tool for GitHub statistics"
99
readme = "README.md"
1010
requires-python = ">=3.8"
@@ -26,7 +26,9 @@ classifiers = [
2626
"Programming Language :: Python :: 3.12",
2727
]
2828

29-
dependencies = []
29+
dependencies = [
30+
"requests>=2.0.0"
31+
]
3032

3133
[project.optional-dependencies]
3234
dev = [
@@ -41,9 +43,9 @@ dev = [
4143
gitfetch = "gitfetch.cli:main"
4244

4345
[project.urls]
44-
Homepage = "https://github.com/yourusername/gitfetch"
45-
Repository = "https://github.com/yourusername/gitfetch"
46-
Issues = "https://github.com/yourusername/gitfetch/issues"
46+
Homepage = "https://github.com/Matars/gitfetch"
47+
Repository = "https://github.com/Matars/gitfetch"
48+
Issues = "https://github.com/Matars/gitfetch/issues"
4749

4850
[tool.setuptools.packages.find]
4951
where = ["src"]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# No Python dependencies required
22
# Requires GitHub CLI (gh) to be installed and authenticated
3+
requests>=2.0.0

src/gitfetch/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,22 @@
22
gitfetch - A neofetch-style CLI tool for GitHub statistics
33
"""
44

5-
__version__ = "0.1.0"
5+
import re
6+
from pathlib import Path
7+
8+
9+
def _get_version() -> str:
10+
"""Get version from pyproject.toml."""
11+
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
12+
try:
13+
with open(pyproject_path, "r", encoding="utf-8") as f:
14+
content = f.read()
15+
match = re.search(r'^version\s*=\s*"([^"]+)"', content, re.MULTILINE)
16+
if match:
17+
return match.group(1)
18+
except (FileNotFoundError, OSError):
19+
pass
20+
return "unknown"
21+
22+
23+
__version__ = _get_version()

src/gitfetch/cli.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from .display import DisplayFormatter
1111
from .cache import CacheManager
1212
from .config import ConfigManager
13+
from . import __version__
1314

1415

1516
def parse_args() -> argparse.Namespace:
@@ -57,8 +58,8 @@ def parse_args() -> argparse.Namespace:
5758

5859
parser.add_argument(
5960
"--version",
60-
action="version",
61-
version="%(prog)s 0.1.0"
61+
action="store_true",
62+
help="Show version and check for updates"
6263
)
6364

6465
return parser.parse_args()
@@ -68,6 +69,26 @@ def main() -> int:
6869
"""Main entry point for the CLI."""
6970
args = parse_args()
7071

72+
if args.version:
73+
print(f"gitfetch version: {__version__}")
74+
# Check for updates from GitHub
75+
import requests
76+
try:
77+
resp = requests.get(
78+
"https://api.github.com/repos/Matars/gitfetch/releases/latest", timeout=3)
79+
if resp.status_code == 200:
80+
latest = resp.json()["tag_name"].lstrip("v")
81+
if latest != __version__:
82+
print(
83+
f"\033[93mUpdate available: {latest}. Get it at https://github.com/Matars/gitfetch/releases/latest\033[0m")
84+
else:
85+
print("You are using the latest version.")
86+
else:
87+
print("Could not check for updates.")
88+
except Exception:
89+
print("Could not check for updates.")
90+
return 0
91+
7192
# Initialize config
7293
config_manager = ConfigManager()
7394

@@ -115,17 +136,13 @@ def main() -> int:
115136
stats = fetcher.fetch_user_stats(username, user_data)
116137
cache_manager.cache_user_data(username, user_data, stats)
117138
else:
118-
# Try to get fresh cache first
119139
user_data = cache_manager.get_cached_user_data(username)
120140
stats = cache_manager.get_cached_stats(username)
121-
122141
if user_data is None or stats is None:
123-
# No fresh cache, try to get stale cache for immediate display
142+
# Try to get stale cache for immediate display
124143
stale_user_data = cache_manager.get_stale_cached_user_data(
125-
username
126-
)
144+
username)
127145
stale_stats = cache_manager.get_stale_cached_stats(username)
128-
129146
if stale_user_data is not None and stale_stats is not None:
130147
# Display stale cache immediately
131148
formatter.display(username, stale_user_data, stale_stats, spaced=spaced)
@@ -139,17 +156,13 @@ def refresh_cache():
139156
try:
140157
fresh_user_data = fetcher.fetch_user_data(username)
141158
fresh_stats = fetcher.fetch_user_stats(
142-
username, fresh_user_data
143-
)
159+
username, fresh_user_data)
144160
cache_manager.cache_user_data(
145-
username, fresh_user_data, fresh_stats
146-
)
161+
username, fresh_user_data, fresh_stats)
147162
except Exception:
148-
pass # Silently fail background refresh
149-
163+
pass
150164
thread = threading.Thread(
151-
target=refresh_cache, daemon=True
152-
)
165+
target=refresh_cache, daemon=True)
153166
thread.start()
154167
return 0
155168
else:
@@ -163,7 +176,6 @@ def refresh_cache():
163176
formatter.display(username, user_data, stats, spaced=spaced)
164177

165178
return 0
166-
167179
except Exception as e:
168180
print(f"Error: {e}", file=sys.stderr)
169181
return 1

src/gitfetch/display.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _determine_layout(self) -> str:
4949
"""Determine layout based on terminal width."""
5050
if self.terminal_width < 80:
5151
return 'minimal'
52-
elif self.terminal_width < 140:
52+
elif self.terminal_width < 100:
5353
return 'compact'
5454
else:
5555
return 'full'
@@ -285,6 +285,10 @@ def add_line(label: str, value: str) -> None:
285285

286286
add_line('Company', user_data.get('company'))
287287
add_line('Website', user_data.get('blog'))
288+
# Add stars amount under website
289+
total_stars = stats.get('total_stars')
290+
if total_stars is not None:
291+
add_line('Stars', f"{total_stars} ⭐")
288292

289293
return lines
290294

@@ -319,6 +323,9 @@ def _format_languages(self, stats: Dict[str, Any]) -> list:
319323
)[:5]
320324

321325
for lang, percentage in sorted_langs:
326+
# Reword 'Jupyter notebook' to 'Jupyter'
327+
if lang.lower() == 'jupyter notebook':
328+
lang = 'Jupyter'
322329
lines.append(self._format_language_line(lang, percentage))
323330

324331
return lines

0 commit comments

Comments
 (0)