diff --git a/add-font.py b/add-font.py index afa036f..9b7d164 100644 --- a/add-font.py +++ b/add-font.py @@ -3,6 +3,7 @@ import hashlib import zipfile from pathlib import Path import shutil +import subprocess def get_font_files(font_folder): @@ -80,6 +81,24 @@ def font_exists(font_name): 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(): 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_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("Remember to commit and push your changes to GitHub manually.") + print("Remember to push your changes to GitHub manually.") if __name__ == "__main__":