-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add helper script to create patch releases from cherry-picked commits #6602
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,56 @@ | ||
#!/bin/bash | ||
|
||
# Script: patch-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: | ||
# ./patch-release.sh <commit1> <commit2> ... | ||
# | ||
# Example: | ||
# ./patch-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 | ||
|
||
GITHUB_REPO="aiidateam/aiida-core" | ||
|
||
# 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 | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Print the summary | ||
echo -e "\n### Cherry-Picked Commits Summary:\n" | ||
for summary in "${commit_summaries[@]}"; do | ||
echo "$summary" | ||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this message could be extended to say something about possible next steps? But I am not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also not sure what should be the next step^^ Read the error message and try to fix it is a bit too generic to be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Also I guess the person using this script should know what their doing. 😅