Last active
May 27, 2020 11:02
-
-
Save mcdruid/359929f59be538839d4912fc00796e17 to your computer and use it in GitHub Desktop.
testing script for https://github.com/xjm/drupal_core_release/pull/12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # @param $1 | |
| # The Drupal 7 version. | |
| # @param $2 | |
| # The old version constant. | |
| # @param $3 | |
| # Whether to remove the 'development version' lines. | |
| function insert_changelog_entry() { | |
| # This assumes the D7 changelog location, because D8 does not maintain a | |
| # list of releases in a changelog. | |
| find="Drupal $2, " | |
| date=$(date +"%Y-%m-%d") | |
| changelog="Drupal $1, $date\\ | |
| -----------------------\\ | |
| - Fixed security issues:\\ | |
| " | |
| # @todo This is relying on a global. | |
| for advisory in "${advisories[@]}" ; do | |
| changelog="$changelog - $advisory\\ | |
| " | |
| done | |
| changelog="$changelog\\ | |
| $find" | |
| grep -q "$find" CHANGELOG.txt | |
| if [ ! $? -eq 0 ] ; then | |
| echo -e "Cannot match version constant $2 in the CHANGELOG. The CHANGELOG must be corrected manually." | |
| exit 1 | |
| fi | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| sed -i '' -e "s/$find/$changelog/1" CHANGELOG.txt | |
| else | |
| sed -i -e "s/$find/$changelog/1" CHANGELOG.txt | |
| fi | |
| if [ "$3" = true ] ; then | |
| dev="Drupal 7.xx, xxxx-xx-xx \(development version\) | |
| ----------------------- | |
| \n" | |
| perl -i -p0e "s/$dev//g" CHANGELOG.txt | |
| fi | |
| } | |
| advisory_count=1 | |
| first_advisory=7 | |
| year=$(date +%Y) | |
| declare -a advisories | |
| declare -a advisory_contributors | |
| for i in $( eval echo {1..$advisory_count} ) | |
| do | |
| advisory_number=$(( $i + $first_advisory - 1 )) | |
| advisory_name=$(printf '%03d' $advisory_number) | |
| advisories[$i]="SA-CORE-$year-$advisory_name" | |
| done | |
| git checkout -- CHANGELOG.txt | |
| insert_changelog_entry 7.71 7.70 true | |
| echo -e "\n####### Remove dev ######\n" | |
| head CHANGELOG.txt | |
| git checkout -- CHANGELOG.txt | |
| insert_changelog_entry 7.71 7.70 false | |
| echo -e "\n####### With dev ######\n" | |
| head CHANGELOG.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment