Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/scripts/commit_hunter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# .github/scripts/commit_hunter.sh
#
# Arg1: the full GitHub comment body
#
set -euo pipefail

COMMENT="$1"

# 1) Remove leading /gitcompare line
BODY="${COMMENT#*\/gitcompare}"

# 2) Normalize Windows line endings
BODY="${BODY//$'\r'/}"

# 3) Split on the first line containing only dashes (allowing spaces)
# We use awk for robustness
GOOD=$(printf '%s\n' "$BODY" \
| awk 'BEGIN{sep="---"}
$0 ~ "^[[:space:]]*" sep "[[:space:]]*$" { exit }
{print}')

BAD=$(printf '%s\n' "$BODY" \
| awk 'BEGIN{sep="---"}
$0 ~ "^[[:space:]]*" sep "[[:space:]]*$" {found=1; next}
found {print}')

# 4) Trim blank lines
trim() { printf '%s\n' "$1" | sed '/^[[:space:]]*$/d'; }
GOOD=$(trim "$GOOD")
BAD=$(trim "$BAD")

# >>> Now you have two variables, GOOD and BAD, containing exactly what you need.
# For example:
echo "Comparing these SHAs from GOOD:"
echo "$GOOD" | grep -oE '[0-9a-f]{7,}'
echo
echo "…against BAD:"
echo "$BAD" | grep -oE '[0-9a-f]{7,}'
echo

# 5) Call your existing compare routine.
# Pass GOOD and BAD as multi-line arguments:
./commit_hunter_core.sh "$GOOD" "$BAD"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is commit_hunter_core.sh file?

22 changes: 22 additions & 0 deletions .github/workflows/gitcompare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .github/workflows/gitcompare.yml
name: GitCompare by Comment

on:
issue_comment:
types: [created]

jobs:
comment_trigger:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '/gitcompare')

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run commit_hunter.sh over full comment
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
chmod +x .github/scripts/commit_hunter.sh
./.github/scripts/commit_hunter.sh "$COMMENT_BODY"
Loading