From 5771f504e999aa8a5fc89212686739d8745b9441 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 13 Jul 2022 20:51:47 -0400 Subject: [PATCH] Forget about assignee for a minute and try to generate the body --- ci-tools/update-nixpkgs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/ci-tools/update-nixpkgs b/ci-tools/update-nixpkgs index 3cb23dc4..748d9862 100755 --- a/ci-tools/update-nixpkgs +++ b/ci-tools/update-nixpkgs @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p nixUnstable git openssh curl +#!nix-shell -i bash -p nixUnstable git openssh curl python3 # ^^ # we get nixUnstable for the diff-closures command, mostly. @@ -58,21 +58,22 @@ if git diff --exit-code origin/develop...; then fi # nix-build -A morph -o result-after -# diff=$(nix --extra-experimental-features nix-command store diff-closures ./result-before/ ./result-after/) +# DIFF=$(nix --extra-experimental-features nix-command store diff-closures ./result-before/ ./result-after/) +DIFF="Hello world" git commit -am "bump nixpkgs version" git push --force origin "${TARGET_BRANCH}:${TARGET_BRANCH}" -BODY=$(cat <<EOF -{ - "id": ${CI_PROJECT_ID}, - "source_branch": "${CI_COMMIT_REF_NAME}", - "target_branch": "${TARGET_BRANCH}", - "remove_source_branch": true, - "title": "WIP: ${CI_COMMIT_REF_NAME}", - "assignee_id":"jcalderone" -} -EOF - ) - -curl -X POST --data "${BODY}" --header "Content-Type: application/json" --header "PRIVATE-TOKEN: ${UPDATE_NIXPKGS_PRIVATE_TOKEN}" "https://${HOST}/api/v4/projects/${CI_PROJECT_ID}/merge_requests" +BODY=$(python3 -c ' +import os, sys, json +print(json.dumps({ + "id": os.environ["CI_PROJECT_ID"], + "source_branch": os.environ["CI_COMMIT_REF_NAME"], + "target_branch": os.environ["TARGET_BRANCH"], + "remove_source_branch": True, + "title": f"WIP: {os.environ["CI_COMMIT_REF_NAME"]}", + "description": sys.argv[1], +})) +' "${DIFF}") + +echo curl -X POST --data "${BODY}" --header "Content-Type: application/json" --header "PRIVATE-TOKEN: ${UPDATE_NIXPKGS_PRIVATE_TOKEN}" "https://${HOST}/api/v4/projects/${CI_PROJECT_ID}/merge_requests" -- GitLab