Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
efb-wechat-slave/pre-commit
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
31 lines (25 sloc)
1 KB
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/local/bin/python3 | |
import pathlib | |
import subprocess | |
PACKAGE = "efb-wechat-slave" | |
ROOT_PATH = subprocess.check_output("git rev-parse --show-toplevel".split())\ | |
.decode().strip() | |
VERSION_FILE = str(pathlib.Path(ROOT_PATH) / PACKAGE / "__version__.py") | |
# commit_msg_path = sys.argv[1] | |
stashed = subprocess.run("git diff --cached --name-only".split(), | |
capture_output=True).stdout.decode().splitlines() | |
# Ignore Crowdin sync commits | |
if any(i.endswith('.po') for i in stashed): | |
print("Discovered pofile stashed, do not bump up version.") | |
exit(0) | |
# Ignore commits with version change | |
if any("__version__.py" in i for i in stashed): | |
print("Discovered version file stashed, do not bump up version.") | |
exit(0) | |
# Bump version by a "dev". | |
bump_py = str(pathlib.Path(ROOT_PATH) / "bump.py") | |
subprocess.run((bump_py, '--allow-dirty', '--no-commit', 'dev'), | |
capture_output=True) | |
subprocess.run(("git", "add", VERSION_FILE), | |
capture_output=True) | |
exit(0) |