forked from aiidateam/aiida-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helper to create minor releases from cherry-picked commits
The script helps with creating a minor release that requires to cherry-pick a list of commits, appends the original commit hash to the cherry-picked commit and creating a short summary of it.
- Loading branch information
1 parent
7057238
commit c71111b
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
# Script: minor-release.sh | ||
# Description: | ||
# Cherry-picks a list of commits, amends each with the original commit hash for tracking, | ||
# and generates a summary from the short github commit messages with links to each commit. | ||
# | ||
# Usage: | ||
# ./minor-release.sh <commit1> <commit2> ... | ||
# | ||
# Example: | ||
# ./minor-release.sh abc1234 def5678 | ||
|
||
set -e | ||
|
||
# Check if at least two arguments are provided (repo and at least one commit) | ||
if [ "$#" -lt 1 ]; then | ||
echo "Usage: $0 <commit1> <commit2> ..." | ||
echo "Example: $0 abc1234 def5678" | ||
exit 1 | ||
fi | ||
|
||
# The first argument is the GitHub repo identifier | ||
GITHUB_REPO="aiidateam/aiida-core" | ||
|
||
# Shift to remove the first argument and leave only commit hashes | ||
shift | ||
|
||
# Create an array to store commit summaries | ||
declare -a commit_summaries=() | ||
|
||
# Loop through each commit hash | ||
for commit in "$@"; do | ||
# Cherry-pick the commit | ||
if git cherry-pick "$commit"; then | ||
# If cherry-pick succeeds, get the short message and short hash | ||
commit_message=$(git log -1 --pretty=format:"%B" HEAD) | ||
original_short_hash=$(git log -1 --pretty=format:"%h" "$commit") | ||
original_long_hash=$(git rev-parse $original_short_hash) | ||
|
||
# Amend the cherry-picked commit to include the original commit ID for tracking | ||
git commit --amend -m "$commit_message" -m "Cherry-pick: $original_long_hash" | ||
|
||
# Format the output as a Markdown list item and add to the array | ||
short_commit_message=$(git log -1 --pretty=format:"%s" HEAD) | ||
cherry_picked_hash=$(git log -1 --pretty=format:"%h" HEAD) | ||
commit_summaries+=("- $short_commit_message [[${commit}]](https://github.com/$GITHUB_REPO/commit/${original_long_hash})") | ||
else | ||
echo "Failed to cherry-pick commit $commit" | ||
# Abort the cherry-pick in case of conflict | ||
git cherry-pick --abort | ||
fi | ||
done | ||
|
||
# Print the summary | ||
echo -e "\n### Cherry-Picked Commits Summary:\n" | ||
for summary in "${commit_summaries[@]}"; do | ||
echo "$summary" | ||
done |