yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
2d775b54d
master
1#!/usr/bin/env python3 2 3import json 4import subprocess 5import sys 6import os 7 8 9def main (): 10try : 11# Read JSON input from stdin 12input_data = json .load (sys .stdin ) 13 14tool_name = input_data .get ("tool_name" ,"" ) 15tool_input = input_data .get ("tool_input" , {}) 16 17# Check if this is a Bash tool with git add/commit command 18if tool_name == "Bash" : 19command = tool_input .get ("command" ,"" ) 20 21# Check if command starts with git add or git commit 22if command .strip ().startswith (("git add" ,"git commit" )): 23"Running formatter before git command..." ,file = sys .stderr ) 24 25# Run the formatter 26try : 27result = subprocess .run ( 28 [ 29"./extras/formatting.sh" , 30"--no-version-check" , 31"--cpp" , 32"--since" , 33"master" , 34 ], 35capture_output = True , 36text = True , 37 ) 38 39if result .returncode != 0 : 40f"Formatter warning: { result . stderr } " ,file = sys .stderr ) 41else : 42"Formatting completed successfully" ,file = sys .stderr ) 43 44except Exception as e : 45f"Formatter error: { e } " ,file = sys .stderr ) 46 47sys .exit (0 ) 48 49except json .JSONDecodeError : 50# Handle JSON decode errors gracefully 51sys .exit (0 ) 52except Exception : 53# Handle any other errors gracefully 54sys .exit (0 ) 55 56 57if __name__ == "__main__" : 58main ()