Created
June 13, 2018 16:40
-
-
Save Dogacel/d4c29ba50b46b76acfabfbaaefa84fb1 to your computer and use it in GitHub Desktop.
Auto run bench for test commits on defenchess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys, os, subprocess | |
from sys import platform | |
subprocess_cmd = '/bin/sh' | |
if platform == "win32": | |
subprocess_cmd = 'C:/Windows/System32/bash.exe' | |
commit_msg_filepath = sys.argv[1] | |
with open(commit_msg_filepath, 'r') as fr: | |
first_line = fr.readline() | |
if "test_stc" in first_line: | |
with open(commit_msg_filepath, 'w') as fw: | |
proc = subprocess.Popen(subprocess_cmd, stdin = subprocess.PIPE, stdout = subprocess.PIPE) | |
stdout, stderr = proc.communicate(b'make bench') | |
fw.write("test_stc:" + stdout.splitlines()[-2][8:].decode("utf-8") + first_line[8:]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions:
chmod +x prepare-commit-msg