From 02f1c2d342c3b786489f25495ae746cc268cb604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=E2=80=99Aquino?= Date: Wed, 20 Nov 2024 11:50:45 -0800 Subject: [PATCH] Add script to help identify duplicate changelog entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a new script to devtools that can be used to help identify duplicate changelog entries. It works by identifying duplicate lines in CHANGELOG.md, and then searching whether each one of those duplicate lines are present in a separate text file (which can be a subset of the changelog that the user is interested in analyzing) No user-facing changes Changelog-None Signed-off-by: Daniel D’Aquino --- devtools/find-changelog-duplicates.sh | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 devtools/find-changelog-duplicates.sh diff --git a/devtools/find-changelog-duplicates.sh b/devtools/find-changelog-duplicates.sh new file mode 100755 index 00000000..d1c4fc98 --- /dev/null +++ b/devtools/find-changelog-duplicates.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Usage function to display help +function usage() { + echo "Usage: $0 " + echo "Where:" + echo " is the file to find duplicates within" + echo " is the file to check these duplicates against" + echo + echo "This script finds duplicate lines in and prints out any" + echo "of these duplicates that exist in ." + exit 1 +} + +# Check for help flag +if [[ "$1" == "-h" || "$1" == "--help" ]]; then + usage +fi + +# Check the number of arguments provided +if [ "$#" -ne 2 ]; then + echo "Error: Two arguments are required." + usage +fi + +# Assign arguments to variables +file1=$1 +file2=$2 + +# Check if files exist +if [ ! -f "$file1" ]; then + echo "Error: File '$file1' does not exist." + exit 1 +fi + +if [ ! -f "$file2" ]; then + echo "Error: File '$file2' does not exist." + exit 1 +fi + +# Find duplicates and check against the second file +sort "$file1" | uniq -d | grep -Fxf - "$file2"