Check if git is dirty before committing (#26588)

This commit is contained in:
Paulus Schoutsen 2019-09-11 13:30:51 -06:00 committed by GitHub
parent 3fbdc89db1
commit df390bc9ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: