Skip to content

Commit

Permalink
Merge pull request #229 from slackingfred/1ststart
Browse files Browse the repository at this point in the history
Fix Git package download
  • Loading branch information
hykilpikonna authored Feb 7, 2024
2 parents a33f85d + f2ed3e7 commit fd5ff6a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion hyfetch/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def default_lightness(self, term: LightDark | None = None) -> float:

GLOBAL_CFG = GlobalConfig(color_mode='8bit', override_distro=None, debug=False, is_light=False, use_overlay=False)

MINGIT_URL = 'https://github.com/git-for-windows/git/releases/download/v2.37.2.windows.2/MinGit-2.37.2.2-busybox-32-bit.zip'
GIT_URL = 'https://github.com/git-for-windows/git/releases/download/v2.37.2.windows.2/Git-2.37.2.2-32-bit.tar.bz2'
26 changes: 14 additions & 12 deletions hyfetch/neofetch_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import shutil
import subprocess
import sys
import zipfile
import tarfile
from dataclasses import dataclass
from pathlib import Path
from subprocess import check_output
Expand All @@ -17,7 +17,7 @@
import pkg_resources

from .color_util import color, printc
from .constants import GLOBAL_CFG, MINGIT_URL, IS_WINDOWS
from .constants import GLOBAL_CFG, GIT_URL, IS_WINDOWS
from .distros import distro_detector
from .presets import ColorProfile
from .serializer import from_dict
Expand Down Expand Up @@ -246,21 +246,23 @@ def ensure_git_bash() -> Path:

# Previously downloaded portable installation
path = Path(__file__).parent / 'min_git'
pkg_path = path / 'package.zip'
if path.is_dir():
return path / r'bin\bash.exe'
portable_bash_exe = path / r'bin\bash.exe'
if path.is_dir() and portable_bash_exe.is_file():
return portable_bash_exe

# No installation found, download a portable installation
print('Git installation not found. Git is required to use HyFetch/neofetch on Windows')
if literal_input('Would you like to install a minimal package for Git? (if no is selected colors almost certainly won\'t work)', ['yes', 'no'], 'yes', False) == 'yes':
print('Downloading a minimal portable package for Git...')
Path.mkdir(path, parents=True, exist_ok=True)
pkg_path = path / 'package.tbz'
print('Git installation not found. Git Bash is required to use HyFetch/neofetch on Windows')
if literal_input('Would you like to download and install Git into HyFetch package directory? (if no is selected colors almost certainly won\'t work)', ['yes', 'no'], 'yes', False) == 'yes':
print('Downloading a portable version of Git...')
from urllib.request import urlretrieve
urlretrieve(MINGIT_URL, pkg_path)
urlretrieve(GIT_URL, pkg_path)
print('Download finished! Extracting...')
with zipfile.ZipFile(pkg_path, 'r') as zip_ref:
zip_ref.extractall(path)
with tarfile.open(pkg_path, 'r:bz2') as tbz_ref:
tbz_ref.extractall(path)
print('Done!')
return path / r'bin\bash.exe'
return portable_bash_exe
else:
sys.exit()

Expand Down

0 comments on commit fd5ff6a

Please sign in to comment.