From 8f62dc983c76edcdf0fc946b0a5ddf3f8a6427cd Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 11 May 2023 12:51:59 -0400 Subject: [PATCH 1/6] Add a tool that allows us to quickly update specification URLs to a specific version. --- .../tools/update_specification_version.sh | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 internal/tools/update_specification_version.sh diff --git a/internal/tools/update_specification_version.sh b/internal/tools/update_specification_version.sh new file mode 100755 index 0000000000..367949588c --- /dev/null +++ b/internal/tools/update_specification_version.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Example usage: +# +# ./internal/tools/update_specification_version.sh + + +# Set this to the version number you want to CHANGE in URLs in the repository. +PREVIOUS_SPECIFICATION_VERSION="1.19.0" +# Set this tot he version number you want to KEEP in URLs in the repository. +LATEST_SPECIFICATOIN_VERSION="1.20.0" +# This the the specific pattern we look for when replacing URLs +SPECIFICATION_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/tree/" + + +fix_file() { + echo Fixing file $1 + sed -i "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},g" $1 +} + +fix_directory() { + # TODO - limit to markdown/yaml files? + for file in $(ls $1); do + if [[ -d "$1/$file" ]]; then + fix_directory "$1/$file" + elif [[ -f "$1/$file" ]]; then + fix_file "$1/$file" + fi + done +} + +important_files=("specification" "semantic_conventions" "README.md" "supplementary-guidelines") + +for file in ${important_files[@]}; do + if [[ -d $file ]]; then + fix_directory "$file" + elif [[ -f $file ]]; then + fix_file "$file" + fi +done From 2b7e4956e10913047036ee66b46c6f156bdcd5ce Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 11 May 2023 13:51:31 -0400 Subject: [PATCH 2/6] Fix tool with real usage. --- internal/tools/update_specification_version.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/tools/update_specification_version.sh b/internal/tools/update_specification_version.sh index 367949588c..f1c9f49abb 100755 --- a/internal/tools/update_specification_version.sh +++ b/internal/tools/update_specification_version.sh @@ -6,16 +6,18 @@ # Set this to the version number you want to CHANGE in URLs in the repository. -PREVIOUS_SPECIFICATION_VERSION="1.19.0" +PREVIOUS_SPECIFICATION_VERSION="main" # Set this tot he version number you want to KEEP in URLs in the repository. LATEST_SPECIFICATOIN_VERSION="1.20.0" # This the the specific pattern we look for when replacing URLs SPECIFICATION_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/tree/" +SPECIFICATION_BLOB_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/blob/" fix_file() { echo Fixing file $1 - sed -i "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},g" $1 + sed -i "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATOIN_VERSION},g" "$1" + sed -i "s,${SPECIFICATION_BLOB_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATOIN_VERSION},g" "$1" } fix_directory() { From ebb46b173ae3c7e6e8cae89c11f768fafa63c1ea Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 11 May 2023 13:55:14 -0400 Subject: [PATCH 3/6] Add documentation for updating referenced specification version. --- CONTRIBUTING.md | 8 ++++++++ internal/tools/update_specification_version.sh | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 987de7212c..11678a3c86 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -114,3 +114,11 @@ To quickly fix typos, use ```bash make misspell-correction ``` + +## Updating the referenced specification version. + +1. Open the `./internal/tools/update_specification_version.sh` script. +2. Modify the `PREVIOUS_SPECIFICATION_VERSION` to be the same value as `LATEST_SPECIFICATION_VERSION` +3. Modify `LATEST_SPECIFICATION_VERSION` to the latest specification tag, e.g. `1.21` +4. Run the script from the root directory, e.g. `semantic-conventions$ ./internal/tools/update_specification_version.sh`. +5. Add all modified files to the change submit and submit a PR. \ No newline at end of file diff --git a/internal/tools/update_specification_version.sh b/internal/tools/update_specification_version.sh index f1c9f49abb..dd9a1d0025 100755 --- a/internal/tools/update_specification_version.sh +++ b/internal/tools/update_specification_version.sh @@ -8,7 +8,7 @@ # Set this to the version number you want to CHANGE in URLs in the repository. PREVIOUS_SPECIFICATION_VERSION="main" # Set this tot he version number you want to KEEP in URLs in the repository. -LATEST_SPECIFICATOIN_VERSION="1.20.0" +LATEST_SPECIFICATION_VERSION="1.20.0" # This the the specific pattern we look for when replacing URLs SPECIFICATION_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/tree/" SPECIFICATION_BLOB_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/blob/" @@ -16,8 +16,8 @@ SPECIFICATION_BLOB_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-s fix_file() { echo Fixing file $1 - sed -i "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATOIN_VERSION},g" "$1" - sed -i "s,${SPECIFICATION_BLOB_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATOIN_VERSION},g" "$1" + sed -i "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" "$1" + sed -i "s,${SPECIFICATION_BLOB_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" "$1" } fix_directory() { From 06fe4e0812a320d9b5f90ff50a4b6c7054844fad Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 11 May 2023 13:58:57 -0400 Subject: [PATCH 4/6] Fix lint error. --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11678a3c86..a60c91aaa1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,10 +115,10 @@ To quickly fix typos, use make misspell-correction ``` -## Updating the referenced specification version. +## Updating the referenced specification version 1. Open the `./internal/tools/update_specification_version.sh` script. 2. Modify the `PREVIOUS_SPECIFICATION_VERSION` to be the same value as `LATEST_SPECIFICATION_VERSION` 3. Modify `LATEST_SPECIFICATION_VERSION` to the latest specification tag, e.g. `1.21` 4. Run the script from the root directory, e.g. `semantic-conventions$ ./internal/tools/update_specification_version.sh`. -5. Add all modified files to the change submit and submit a PR. \ No newline at end of file +5. Add all modified files to the change submit and submit a PR. From f6b3b1c502d51a39996870cc8e756da448a6df9f Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 15 May 2023 10:17:48 -0400 Subject: [PATCH 5/6] Apply suggestions from code review Thanks for the scripting help! Co-authored-by: Liudmila Molkova Co-authored-by: Johannes Tax --- .../tools/update_specification_version.sh | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/internal/tools/update_specification_version.sh b/internal/tools/update_specification_version.sh index dd9a1d0025..4061d8d114 100755 --- a/internal/tools/update_specification_version.sh +++ b/internal/tools/update_specification_version.sh @@ -7,9 +7,9 @@ # Set this to the version number you want to CHANGE in URLs in the repository. PREVIOUS_SPECIFICATION_VERSION="main" -# Set this tot he version number you want to KEEP in URLs in the repository. +# Set this to the version number you want to KEEP in URLs in the repository. LATEST_SPECIFICATION_VERSION="1.20.0" -# This the the specific pattern we look for when replacing URLs +# The specific pattern we look for when replacing URLs SPECIFICATION_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/tree/" SPECIFICATION_BLOB_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-specification/blob/" @@ -20,23 +20,9 @@ fix_file() { sed -i "s,${SPECIFICATION_BLOB_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" "$1" } -fix_directory() { - # TODO - limit to markdown/yaml files? - for file in $(ls $1); do - if [[ -d "$1/$file" ]]; then - fix_directory "$1/$file" - elif [[ -f "$1/$file" ]]; then - fix_file "$1/$file" - fi - done -} - important_files=("specification" "semantic_conventions" "README.md" "supplementary-guidelines") -for file in ${important_files[@]}; do - if [[ -d $file ]]; then - fix_directory "$file" - elif [[ -f $file ]]; then - fix_file "$file" - fi +# TODO - limit to markdown/yaml files? +find "${important_files[@]}" -type f -not -path '*/.*' -print0 | while read -d $'\0' file; do + fix_file "$file" done From 85c5f3815753d383c9db7be717502cc7ac83139c Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 16 May 2023 12:21:40 -0400 Subject: [PATCH 6/6] Update internal/tools/update_specification_version.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improvements from code review Co-authored-by: Christian Neumüller --- internal/tools/update_specification_version.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/tools/update_specification_version.sh b/internal/tools/update_specification_version.sh index 4061d8d114..ccc195c6ca 100755 --- a/internal/tools/update_specification_version.sh +++ b/internal/tools/update_specification_version.sh @@ -16,8 +16,10 @@ SPECIFICATION_BLOB_URL_PREFIX="https://github.com/open-telemetry/opentelemetry-s fix_file() { echo Fixing file $1 - sed -i "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" "$1" - sed -i "s,${SPECIFICATION_BLOB_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" "$1" + sed -i \ + -e "s,${SPECIFICATION_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" \ + -e "s,${SPECIFICATION_BLOB_URL_PREFIX}${PREVIOUS_SPECIFICATION_VERSION},${SPECIFICATION_URL_PREFIX}${LATEST_SPECIFICATION_VERSION},g" \ + "$1" } important_files=("specification" "semantic_conventions" "README.md" "supplementary-guidelines")