Check if git is dirty before committing (#26588)
This commit is contained in:
parent
3fbdc89db1
commit
df390bc9ab
1 changed files with 7 additions and 1 deletions
|
@ -108,7 +108,7 @@ def write_version(version):
|
||||||
|
|
||||||
content = re.sub("MAJOR_VERSION = .*\n", f"MAJOR_VERSION = {major}\n", content)
|
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("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:
|
with open("homeassistant/const.py", "wt") as fil:
|
||||||
content = fil.write(content)
|
content = fil.write(content)
|
||||||
|
@ -126,9 +126,15 @@ def main():
|
||||||
"--commit", action="store_true", help="Create a version bump commit."
|
"--commit", action="store_true", help="Create a version bump commit."
|
||||||
)
|
)
|
||||||
arguments = parser.parse_args()
|
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__)
|
current = Version(const.__version__)
|
||||||
bumped = bump_version(current, arguments.type)
|
bumped = bump_version(current, arguments.type)
|
||||||
assert bumped > current, "BUG! New version is not newer than old version"
|
assert bumped > current, "BUG! New version is not newer than old version"
|
||||||
|
|
||||||
write_version(bumped)
|
write_version(bumped)
|
||||||
|
|
||||||
if not arguments.commit:
|
if not arguments.commit:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue