You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2026/08/13 13:06:40 UTC
svn commit: r86761 - dev/jackrabbit
Author: reschke
Date: Thu Aug 13 13:06:40 2026
New Revision: 86761
Log:
commit/ticket validator
Added:
dev/jackrabbit/check-commits.sh
Added: dev/jackrabbit/check-commits.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ dev/jackrabbit/check-commits.sh Thu Aug 13 13:06:40 2026 (r86761)
@@ -0,0 +1,154 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# --- CONFIG ---
+BRANCH="trunk"
+JIRA_URL="https://issues.apache.org/jira"
+
+# --- USAGE FUNCTION ---
+usage() {
+ echo "Usage: $0 --tag <tag> --fixVersion <fixVersion> [--repo <path>] [--help]"
+ echo
+ echo "Options:"
+ echo " -t, --tag <tag> Git tag or range to check (Required)"
+ echo " -f, --fixVersion <ver> Expected Jira Fix Version (Required)"
+ echo " -r, --repo <path> Path to the local Git repository (Default: current directory)"
+ echo " -h, --help Display this help message and exit"
+ exit 1
+}
+
+# --- ARGUMENT PARSING ---
+TAG=""
+FIX_VERSION=""
+REPO="$(pwd)"
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -t|--tag)
+ TAG="$2"
+ shift 2
+ ;;
+ -f|--fixVersion)
+ FIX_VERSION="$2"
+ shift 2
+ ;;
+ -r|--repo)
+ REPO="$2"
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ ;;
+ *)
+ echo "Unknown option: $1" >&2
+ usage
+ ;;
+ esac
+done
+
+# Validate required options
+if [[ -z "$TAG" ]] || [[ -z "$FIX_VERSION" ]]; then
+ echo "Error: Both --tag (-t) and --fixVersion (-f) are required command-line options." >&2
+ usage
+fi
+
+WORKDIR=$(mktemp -d)
+cd "$WORKDIR"
+
+echo "Working in $WORKDIR"
+
+# --- 1. Get commits ---
+git -C "$REPO" fetch origin >/dev/null 2>&1
+git -C "$REPO" checkout "$BRANCH" >/dev/null 2>&1
+
+git -C "$REPO" log "${TAG}..${BRANCH}" \
+ --pretty=format:"%H|%s" > commits.txt
+
+echo "Total commits: $(wc -l < commits.txt)"
+
+# --- 2. Commits WITHOUT JIRA ---
+grep -vE 'OAK-[0-9]+' commits.txt > commits_without_jira.txt || true
+echo "Commits without JIRA: $(wc -l < commits_without_jira.txt)"
+
+# --- 3. Extract JIRA IDs ---
+grep -Eo 'OAK-[0-9]+' commits.txt | sort -u > jira_ids.txt || true
+echo "Unique JIRA tickets: $(wc -l < jira_ids.txt)"
+
+# --- 4. Fetch JIRA details (NO AUTH) ---
+> jira_details.txt
+
+while read -r issue; do
+ [[ -z "$issue" ]] && continue
+
+ response=$(curl -s \
+ "$JIRA_URL/rest/api/2/issue/$issue")
+
+ status=$(echo "$response" | jq -r '.fields.status.name // "UNKNOWN"')
+ fixVersions=$(echo "$response" | jq -r '.fields.fixVersions[].name' 2>/dev/null | tr '\n' ',')
+
+ echo "$issue|$status|$fixVersions" >> jira_details.txt
+
+done < jira_ids.txt
+
+# --- 5. Filter invalid JIRA (using dynamic --fixVersion) ---
+> invalid_jira.txt
+
+while IFS='|' read -r issue status fixVersions; do
+ if [[ "$status" != "Resolved" ]] || [[ "$fixVersions" != *"$FIX_VERSION"* ]]; then
+ echo "$issue"
+ fi
+done < jira_details.txt > invalid_jira.txt
+
+echo "Invalid JIRA tickets: $(wc -l < invalid_jira.txt)"
+
+# --- 6. Map back to commits (Extract full line matching the invalid JIRA ID) ---
+> commits_with_invalid_jira.txt
+while read -r invalid_issue; do
+ [[ -z "$invalid_issue" ]] && continue
+ grep -E "\b${invalid_issue}\b" commits.txt >> commits_with_invalid_jira.txt || true
+done < invalid_jira.txt
+
+# Deduplicate in case multiple invalid issues match a single commit line
+sort -u commits_with_invalid_jira.txt -o commits_with_invalid_jira.txt
+
+echo "Commits with invalid JIRA: $(wc -l < commits_with_invalid_jira.txt)"
+
+# --- 7. Combine ---
+cat commits_without_jira.txt commits_with_invalid_jira.txt \
+ | sort -u > problematic_commits.txt
+
+echo "Total problematic commits: $(wc -l < problematic_commits.txt)"
+
+# --- 8. Summary Display ---
+echo
+echo "========================================"
+echo "## Execution Summary"
+echo "========================================"
+
+echo
+echo "### ❌ Commits Without Jira ($(wc -l < commits_without_jira.txt))"
+if [[ -s commits_without_jira.txt ]]; then
+ while IFS='|' read -r commit_hash commit_msg; do
+ echo " * \`$commit_hash\` - $commit_msg"
+ done < commits_without_jira.txt
+else
+ echo " * *None found. Excellent!*"
+fi
+
+echo
+echo "### ⚠️ Commits With Incorrect Jira Status/Version ($(wc -l < commits_with_invalid_jira.txt))"
+if [[ -s commits_with_invalid_jira.txt ]]; then
+ while IFS='|' read -r commit_hash commit_msg; do
+ echo " * \`$commit_hash\` - $commit_msg"
+ done < commits_with_invalid_jira.txt
+else
+ echo " * *None found. Excellent!*"
+fi
+
+echo
+echo "========================================"
+echo "Outputs generated:"
+echo " commits_without_jira.txt"
+echo " commits_with_invalid_jira.txt"
+echo " problematic_commits.txt"