Skip to content

Commit

Permalink
Improve changelog step's state handling when continuing after failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackenmen committed Sep 14, 2023
1 parent 3a2a1b8 commit c662c37
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions tools/release_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,40 +536,46 @@ def create_changelog(release_type: ReleaseType, version: str) -> None:
else:
changelog_branch = f"V3/changelogs/{version}"
subprocess.check_call(("git", "fetch", GH_URL))
try:
subprocess.check_call(("git", "checkout", "-b", changelog_branch, "FETCH_HEAD"))
except subprocess.CalledProcessError:
rich.print()
if click.confirm(
f"It seems that {changelog_branch} branch already exists, do you want to use it?"
):
subprocess.check_call(("git", "checkout", changelog_branch))
elif not click.confirm("Do you want to use a different branch?"):
raise click.ClickException("Can't continue without a changelog branch...")
elif click.confirm("Do you want to create a new branch?"):
while True:
changelog_branch = click.prompt("Input the name of the new branch")
try:
subprocess.check_call(
("git", "checkout", "-b", changelog_branch, "FETCH_HEAD")
)
except subprocess.CalledProcessError:
continue
else:
break
else:
while True:
changelog_branch = click.prompt("Input the name of the branch to check out")
try:
subprocess.check_call(("git", "checkout", changelog_branch))
except subprocess.CalledProcessError:
continue
else:
break

set_changelog_branch(changelog_branch)
set_release_stage(ReleaseStage.CHANGELOG_BRANCH_EXISTS)

try:
subprocess.check_call(("git", "checkout", "-b", changelog_branch, "FETCH_HEAD"))
except subprocess.CalledProcessError:
rich.print()
if click.confirm(
f"It seems that {changelog_branch} branch already exists, do you want to use it?"
):
subprocess.check_call(("git", "checkout", changelog_branch))
elif not click.confirm("Do you want to use a different branch?"):
raise click.ClickException("Can't continue without a changelog branch...")
elif click.confirm("Do you want to create a new branch?"):
while True:
changelog_branch = click.prompt("Input the name of the new branch")
try:
subprocess.check_call(
("git", "checkout", "-b", changelog_branch, "FETCH_HEAD")
)
except subprocess.CalledProcessError:
continue
else:
break
else:
while True:
changelog_branch = click.prompt("Input the name of the branch to check out")
try:
subprocess.check_call(("git", "checkout", changelog_branch))
except subprocess.CalledProcessError:
continue
else:
break

set_changelog_branch(changelog_branch)
set_release_stage(ReleaseStage.CHANGELOG_BRANCH_EXISTS)

title = f"Red {version} - Changelog"
commands = [
("git", "add", "."),
("git", "commit", "-m", title),
("git", "push", "-u", GH_URL, f"{changelog_branch}:{changelog_branch}"),
]
if get_release_stage() < ReleaseStage.CHANGELOG_COMMITTED:
rich.print(
"\n:pencil: At this point, you should have an up-to-date milestone"
Expand Down Expand Up @@ -598,12 +604,6 @@ def create_changelog(release_type: ReleaseType, version: str) -> None:
if option == "4":
break

title = f"Red {version} - Changelog"
commands = [
("git", "add", "."),
("git", "commit", "-m", title),
("git", "push", "-u", GH_URL, f"{changelog_branch}:{changelog_branch}"),
]
print(
"Do you want to commit everything from repo's working tree and push it?"
" The following commands will run:"
Expand Down

0 comments on commit c662c37

Please sign in to comment.