-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
21 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,22 @@ | ||
#!/bin/bash | ||
|
||
# The input is a comma-separated list of commit hashes | ||
if [ -z "$repo" ]; then | ||
echo "Repo is not defined" | ||
exit 1 | ||
fi | ||
if [ -z "$org" ]; then | ||
echo "Org is not defined" | ||
exit 1 | ||
fi | ||
if [ -z "$issue" ]; then | ||
echo "Issue number is not defined" | ||
exit 1 | ||
fi | ||
if [ -z "$body" ]; then | ||
echo "Body number is not defined" | ||
exit 1 | ||
fi | ||
|
||
echo "https://github.com/$org/$repo" | ||
gh issue comment $issue --body "$body" -R "https://github.com/$org/$repo" |
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,18 @@ | ||
#!/bin/bash | ||
|
||
# The input is a comma-separated list of commit hashes | ||
if [ -z "$repo" ]; then | ||
echo "Repo is not defined" | ||
exit 1 | ||
fi | ||
if [ -z "$org" ]; then | ||
echo "Org is not defined" | ||
exit 1 | ||
fi | ||
if [ -z "$issue" ]; then | ||
echo "Issue number is not defined" | ||
exit 1 | ||
fi | ||
|
||
echo "https://github.com/$org/$repo" | ||
gh issue close $issue -R "https://github.com/$org/$repo" |
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 |
---|---|---|
@@ -1,18 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# The input is a comma-separated list of commit hashes | ||
echo "Starting checrry-pick..." | ||
echo "Starting cherry-pick..." | ||
if [ -z "$branch" ]; then | ||
echo "Branch is not defined" | ||
exit 1 | ||
fi | ||
git checkout -b $branch | ||
echo "https://github.com/$org/$repo" | ||
|
||
commit_hashes_arr="$commit_list" | ||
echo "sha commiits: commit_hashes_arr" | ||
normalized=$(echo "$commit_hashes_arr" | tr '.,\n' ' ') | ||
readarray -d " " -t commit_hashes <<< "$normalized" | ||
for word in $commit_hashes_arr; do | ||
# Append word to the list | ||
commit_hashes="$commit_hashes $word" | ||
done | ||
echo "commit_hashes: $commit_hashes" | ||
|
||
if [[ "$branch" == "rc" ]]; then | ||
orig_branch="main" | ||
else | ||
orig_branch="rc" | ||
fi | ||
echo "original branch: $orig_branch" | ||
|
||
git fetch --all | ||
for commit_hash in $commit_hashes; do | ||
# Check if commit exists in current branch | ||
cmt=$(git branch -r --contains $commit_hash | sed 's/origin\///') | ||
cmt=$(echo "$cmt" | sed 's/^[ \t]*//;s/[ \t]*$//') | ||
echo "cmt2=$cmt" | ||
if [ -z "$cmt" ]; then | ||
echo "Commit $commit_hash does not exists" | ||
exit 1 | ||
fi | ||
if [[ $cmt != $orig_branch ]]; then | ||
echo "Commit $commit_hash does not belong to original branch $orig_branch" | ||
exit 1 | ||
fi | ||
done | ||
|
||
git clone -b $branch "https://github.com/$org/$repo" chp || { | ||
echo "Something wnet wrong with clone branch" | ||
exit 1 | ||
} | ||
cd chp | ||
|
||
echo $(git branch --show-current) | ||
rc=$(git branch --show-current) | ||
if [ -z "$rc" ]; then | ||
echo "Please go to git branch and run script from there" | ||
|
@@ -31,31 +62,33 @@ if [ -z "$commit_hashes" ]; then | |
exit 1 | ||
fi | ||
|
||
# Initialize an array to hold the sorted commit hashes | ||
declare -a sorted_commits | ||
|
||
# Initialize a space-separated string to hold sorted commit hashes | ||
sorted_commits="" | ||
# Loop through the hashes, get their commit dates, and sort them | ||
# Then read line by line into the array | ||
while IFS= read -r line; do | ||
sorted_commits+=("$line") | ||
done < <(for commit in $commit_hashes; do | ||
# Using %ci to get the commit date, you can also use %ct for UNIX timestamp | ||
echo $(git show -s --format=%ci $commit) $commit | ||
# Capture the sorted hashes into a string variable | ||
sorted_commits=$(for commit in $commit_hashes; do | ||
# Get the commit date using %ci, output with commit hash | ||
commit_info=$(git show -s --format=%ci $commit) | ||
echo "$commit_info $commit" | ||
done | sort | awk '{print $4}') | ||
|
||
# Now, you can use sorted_commits array as needed | ||
echo "Sorted commits:" | ||
printf "%s\n" "${sorted_commits[@]}" | ||
# Loop through the array and cherry-pick each commit from the "main" branch | ||
for commit_hash in "${sorted_commits[@]}"; do | ||
echo "Cherry-picking commit $commit_hash from main to rc..." | ||
SCRIPT_DIR="$(dirname "$(realpath "$0")")" | ||
echo "The script directory is: $SCRIPT_DIR" | ||
# Process each sorted commit hash separately | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "upload-robot" | ||
for commit_hash in $sorted_commits; do | ||
echo "Cherry-picking commit $commit_hash from main to $branch..." | ||
echo $(git show -s --format=%ci $commit_hash) $commit_hash | ||
commit_hash=$(echo $commit_hash | tr -d ' ') | ||
echo "commiting sha: $commit_hash" | ||
git cherry-pick "$commit_hash" || { | ||
echo "Error cherry-picking commit $commit_hash. Aborting." | ||
exit 1 | ||
} | ||
git push origin $rc | ||
done | ||
git config --global url.https://$github_token@github.com/.insteadOf https://github.com/ | ||
git push origin $rc | ||
|
||
echo "Cherry-pick completed successfully." |