Return URL where they can view changes and open PR

This commit is contained in:
mike cullerton 2022-12-08 09:26:10 -05:00
parent a2c7411b3d
commit 3530a628ec
3 changed files with 16 additions and 4 deletions

View File

@ -470,7 +470,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/OkTrue"
type: string
/processes:
get:

View File

@ -377,8 +377,9 @@ def process_model_publish(
if branch_to_update is None:
branch_to_update = current_app.config["GIT_MERGE_BRANCH"]
process_model_identifier = un_modify_modified_process_model_id(modified_process_model_identifier)
GitService().publish(process_model_identifier, branch_to_update)
return Response(json.dumps({"ok": True}), status=200, mimetype="application/json")
pr_url = GitService().publish(process_model_identifier, branch_to_update)
data = {"ok": True, "pr_url": pr_url}
return Response(json.dumps(data), status=200, mimetype="application/json")
def process_model_list(

View File

@ -94,4 +94,15 @@ class GitService:
commit_message = f"Request to publish changes to {process_model_id}, from {g.user.username}"
os.system(f"git commit -m '{commit_message}'") # noqa: S605
os.system("git push")
print("publish")
# build url for github page to open PR
output = os.popen("git remote -v").read()
remote_url = output.strip().split("\n")[0].split("\t")[1].split(" ")[0].replace(".git", "")
pr_url = f"{remote_url}/compare/{publish_branch}?expand=1"
# try to clean up
os.chdir("/tmp")
if os.path.exists(destination_process_root):
shutil.rmtree(destination_process_root)
return pr_url