Skip to content

Commit

Permalink
update voedger version with empty cherry-pick
Browse files Browse the repository at this point in the history
  • Loading branch information
ivvist committed Jun 2, 2024
1 parent fd365cf commit 991bdb4
Showing 1 changed file with 52 additions and 27 deletions.
79 changes: 52 additions & 27 deletions scripts/cp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,50 @@ if [ -z "$branch" ]; then
fi
echo "https://github.com/$org/$repo"

if [ -z "$branch" ]; then
commit_hashes_arr="$commit_list"
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"
trimmedsha=$(echo "$commit_hashes" | sed 's/^[ \t]*//;s/[ \t]*$//')
lengthsha=${#trimmedsha}
if [ $lengthsha -eq 0 ]; then
if [[ "$repo" == "airs-bp3" ]]; then
echo "No commits are required to cherry-pick. Will upgrade voedger version."
else
echo "List of commits to cherry-pick is empty"
exit 1
fi
else
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 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
fi

git clone -b $branch "https://github.com/$org/$repo" chp || {
echo "Something wnet wrong with clone branch"
echo "Something went wrong with clone branch"
exit 1
}
cd chp
Expand All @@ -53,16 +65,24 @@ if [ "$rc" = "main" ]; then
echo "Please go to git branch and run script from there. It does not in main."
exit 1
fi

echo "Current branch: $rc"


# Check if commit hashes were provided
if [ -z "$commit_hashes" ]; then
echo "Usage: $0 <comma-separated list of commit hashes>"
exit 1
if [ $lengthsha -eq 0 ]; then # Means pb3 wans to update voedger version
git config --local user.email "[email protected]"
git config --local user.name "upload-robot"
git config --global url.https://$github_token@github.com/.insteadOf https://github.com/
if [[ "$branch" == "rc" ]]; then
go get github.com/voedger/voedger@rc
else
go get github.com/voedger/voedger@release
go mod tidy
git commit -am "Cherry-pick auto-create" --allow-empty
git push origin $rc
exit 0
fi


# Initialize a space-separated string to hold sorted commit hashes
sorted_commits=""
# Loop through the hashes, get their commit dates, and sort them
Expand All @@ -89,6 +109,11 @@ for commit_hash in $sorted_commits; do
}
done
git config --global url.https://$github_token@github.com/.insteadOf https://github.com/
if [[ "$branch" == "rc" ]]; then
go get github.com/voedger/voedger@rc
else
go get github.com/voedger/voedger@release
go mod tidy
git commit -am "Cherry-pick auto-create" --allow-empty
git push origin $rc

Expand Down

0 comments on commit 991bdb4

Please sign in to comment.