Skip to content

Instantly share code, notes, and snippets.

@b0noI
Created April 20, 2023 00:17
Show Gist options
  • Save b0noI/f15f8e1e97ace60e8c5c823ce89475d4 to your computer and use it in GitHub Desktop.
Save b0noI/f15f8e1e97ace60e8c5c823ce89475d4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Check if the input parameters are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <date> <number>"
exit 1
fi
date_input="$1"
number="$2"
# Calculate the total number of commits from the specified date until the latest commit
total_commits=$(git log --since="$date_input" --format=oneline | wc -l)
# Calculate the step between commits
step=$(($total_commits / ($number - 1)))
# Find the oldest commit hash from the specified date
oldest_commit_hash=$(git log --since="$date_input" --reverse --format="%H" -n 1)
echo "Total commits: $total_commits"
echo "Oldest commit: $oldest_commit_hash"
echo "Step: $step"
# Start the script for the oldest commit
./start_test.sh "$oldest_commit_hash"
# Start the script for other commits, evenly spread
for i in $(seq 1 $((number - 2))); do
commit_hash=$(git log --skip=$(($i * step)) --format="%H" -n 1)
echo "Commit $commit_hash is being tested."
./start_test.sh "$commit_hash"
done
# Start the script for the latest commit
latest_commit_hash=$(git log --format="%h" -n 1)
./start_test.sh "$latest_commit_hash"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment