update the add-font script
This commit is contained in:
parent
5eaaea9ca8
commit
1cf1b5527c
1 changed files with 23 additions and 1 deletions
24
add-font.py
24
add-font.py
|
|
@ -3,6 +3,7 @@ import hashlib
|
||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def get_font_files(font_folder):
|
def get_font_files(font_folder):
|
||||||
|
|
@ -80,6 +81,24 @@ def font_exists(font_name):
|
||||||
return os.path.exists(formula_path)
|
return os.path.exists(formula_path)
|
||||||
|
|
||||||
|
|
||||||
|
def stage_and_commit_changes(font_name, font_folder_path, formula_path):
|
||||||
|
"""Stage only the new font zip file and the formula file, then commit."""
|
||||||
|
try:
|
||||||
|
# Stage the new font zip file
|
||||||
|
zip_file_path = font_folder_path / f"{font_name.lower()}.zip"
|
||||||
|
subprocess.run(["git", "add", str(zip_file_path)], check=True)
|
||||||
|
|
||||||
|
# Stage the formula file from the Formula folder
|
||||||
|
formula_in_formula_folder = f"./Formula/{font_name.lower()}.rb"
|
||||||
|
subprocess.run(["git", "add", formula_in_formula_folder], check=True)
|
||||||
|
|
||||||
|
# Commit with a default message
|
||||||
|
commit_message = f"Add {font_name} font"
|
||||||
|
subprocess.run(["git", "commit", "-m", commit_message], check=True)
|
||||||
|
print(f"Changes staged and committed with message: '{commit_message}'")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error while staging or committing: {e}")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
font_folder = input("Enter the location of the font folder: ").strip()
|
font_folder = input("Enter the location of the font folder: ").strip()
|
||||||
|
|
||||||
|
|
@ -120,8 +139,11 @@ def main():
|
||||||
# Move the formula to the Formula directory
|
# Move the formula to the Formula directory
|
||||||
move_formula_to_formula_folder(formula_path)
|
move_formula_to_formula_folder(formula_path)
|
||||||
|
|
||||||
|
# Stage and commit the changes (only the font and its formula)
|
||||||
|
stage_and_commit_changes(font_package_name, font_folder_path, formula_path)
|
||||||
|
|
||||||
print(f"Font {font_package_name} has been added successfully.")
|
print(f"Font {font_package_name} has been added successfully.")
|
||||||
print("Remember to commit and push your changes to GitHub manually.")
|
print("Remember to push your changes to GitHub manually.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue