From df390bc9ab45f1e34d1a0aa6ef02ee7d53184a82 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 11 Sep 2019 13:30:51 -0600 Subject: [PATCH] Check if git is dirty before committing (#26588) --- script/version_bump.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/script/version_bump.py b/script/version_bump.py index d5df8e66902..de6638df30b 100755 --- a/script/version_bump.py +++ b/script/version_bump.py @@ -108,7 +108,7 @@ def write_version(version): content = re.sub("MAJOR_VERSION = .*\n", f"MAJOR_VERSION = {major}\n", content) content = re.sub("MINOR_VERSION = .*\n", f"MINOR_VERSION = {minor}\n", content) - content = re.sub("PATCH_VERSION = .*\n", f"PATCH_VERSION = '{patch}'\n", content) + content = re.sub("PATCH_VERSION = .*\n", f'PATCH_VERSION = "{patch}"\n', content) with open("homeassistant/const.py", "wt") as fil: content = fil.write(content) @@ -126,9 +126,15 @@ def main(): "--commit", action="store_true", help="Create a version bump commit." ) arguments = parser.parse_args() + + if arguments.commit and subprocess.run(["git", "diff", "--quiet"]).returncode == 1: + print("Cannot use --commit because git is dirty.") + return + current = Version(const.__version__) bumped = bump_version(current, arguments.type) assert bumped > current, "BUG! New version is not newer than old version" + write_version(bumped) if not arguments.commit: