Prechádzať zdrojové kódy

install_extras: git-whence

raylu 2 rokov pred
rodič
commit
c39238cf93
1 zmenil súbory, kde vykonal 22 pridanie a 6 odobranie
  1. 22 6
      install_extras.py

+ 22 - 6
install_extras.py

@@ -14,6 +14,7 @@ CURRENT_DIR = pathlib.Path(__file__).parent
 def main():
 	delta()
 	eza()
+	git_whence()
 
 def delta():
 	if platform.system() == 'Darwin':
@@ -56,13 +57,28 @@ def eza():
 		return
 
 	client = httpx.Client()
-	if platform.system() == 'Linux':
-		url = f'https://github.com/eza-community/eza/releases/latest/download/eza_{platform.machine()}-unknown-linux-gnu.tar.gz'
-		download(client, url, CURRENT_DIR / 'eza.tar.gz')
-		with tarfile.open(CURRENT_DIR / 'eza.tar.gz', 'r:gz') as tar:
-			tar.extract('./eza', CURRENT_DIR)
-		os.unlink(CURRENT_DIR / 'eza.tar.gz')
+	url = f'https://github.com/eza-community/eza/releases/latest/download/eza_{platform.machine()}-unknown-linux-gnu.tar.gz'
+	download(client, url, CURRENT_DIR / 'eza.tar.gz')
+	with tarfile.open(CURRENT_DIR / 'eza.tar.gz', 'r:gz') as tar:
+		tar.extract('./eza', CURRENT_DIR)
+	os.unlink(CURRENT_DIR / 'eza.tar.gz')
 
+def git_whence():
+	if platform.system() == 'Darwin':
+		print('$ brew install raylu/formulae/git-whence')
+		subprocess.run(['brew', 'install', 'raylu/formulae/git-whence'], check=True)
+		return
+	else:
+		assert platform.system() == 'Linux'
+
+	if (CURRENT_DIR / 'git-whence').exists():
+		print('git-whence already downloaded')
+		return
+
+	client = httpx.Client()
+	url = f'https://github.com/raylu/git-whence/releases/latest/download/git-whence-{platform.machine()}-unknown-linux-gnu'
+	download(client, url, CURRENT_DIR / 'git-whence')
+	os.chmod(CURRENT_DIR / 'git-whence', 0o755)
 
 def get_output(argv: list[str]) -> str:
 	proc = subprocess.run(argv, check=True, capture_output=True, encoding='ascii')