-
Notifications
You must be signed in to change notification settings - Fork 505
Reviewing PRs
Matthew Casperson edited this page Dec 12, 2023
·
3 revisions
Pull requests for step templates embed a lot of the important changes in a single JSON string property. This makes it hard to review a PR using a direct diff.
The script below extracts the step property containing the important changes and displays the diff between the mainline and branch versions:
#!/bin/bash
cd /tmp
rm -rf Library
git clone https://github.com/OctopusDeploy/Library.git
cd Library
syntax=$(jq -r '.Properties."Octopus.Action.Script.Syntax"' step-templates/$2.json)
case $syntax in
"PowerShell")
fileExt="ps1"
;;
"Bash")
fileExt="sh"
;;
"Python")
fileExt="py"
;;
*)
fileExt="txt"
;;
esac
# The property extracted here depends on the step template. For example, a Terraform step template will
# need to diff the "Octopus.Action.Terraform.Template" property.
jq -r '.Properties."Octopus.Action.Script.ScriptBody"' $2 > /tmp/master.$fileExt
git switch $1
jq -r '.Properties."Octopus.Action.Script.ScriptBody"' $2 > /tmp/branch.$fileExt
# Now diff between the two files
# Replace this command with your own diff tool
# The example below assumes kdiff3 installed as a Flatpak
flatpak run --file-forwarding org.kde.kdiff3 @@ /tmp/master.$fileExt @@ @@ /tmp/branch.$fileExt @@
Usage:
./review.sh mattc/fix_dependencies step-templates/octopus-reference-architecture-eks.json
The branch and filenames can be copied directly from the GitHub web based interface: