Skip to content

Commit befdd42

Browse files
committed
Move force pushing to allowlist only
1 parent ea64e8f commit befdd42

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

hooks/post_gen_project.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,21 @@ def run_post_gen_hook():
200200
)
201201

202202
if os.environ.get("SKIP_GIT_PUSH") != "true":
203+
cmd = ["git", "push", "--set-upstream", "origin", "main"]
204+
205+
# We only force push if we were explicitly allowed to
206+
if os.environ.get("ALLOW_FORCE_PUSH") == "true":
207+
cmd.append("--force")
208+
203209
subprocess.run(
204-
["git", "push", "--set-upstream", "origin", "main", "--force"],
210+
cmd,
205211
capture_output=True,
206212
check=True,
207213
)
208214

215+
# If the user didn't set ALLOW_FORCE_PUSH to true, and the project already existed, it should have failed when it previously attempted to push, so
216+
# we will never get to this step
217+
#
209218
# Cleanup the v0.1.0 tag if it already exists, so the following release will succeed and repoint the tag if it's this is a regeneration
210219
subprocess.run(
211220
["git", "push", "--delete", "origin", "v0.1.0"],

0 commit comments

Comments
 (0)