Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set -e
- git clone --branch "$branch" --depth 1 "$repository" "$clone_path"
- cd "$clone_path"
- git fetch "$upstream_repository" "$upstream_branch":upstream
- echo "upstream_last_commit=$(git log --pretty='%H' --max-count 1 upstream)" >> "$GITHUB_OUTPUT"
- last_rebased_tag="$(git describe --tags --match="upstream-commit-[0-9a-z]*" "$branch")"
- last_rebased_hash="$(git tag --format='%(subject)' -l "$last_rebased_tag")"
- echo "Pickup commit $last_rebased_hash from where last rebase finished."
- hash_before_rebase="$(git log --max-count 1 --pretty='%H')"
- git rebase --onto "$branch" "$last_rebased_hash" upstream || rebase_errno=$?
- hash_after_rebase="$(git log --max-count 1 --pretty='%H')"
- if [ "$rebase_errno" ];
- then
- echo "Rebase failed, trying to best-effort it."
- git rebase --abort
- fi
- if [ "$hash_before_rebase" == "$hash_after_rebase" ];
- then
- echo "Same hash before and after rebasing, exiting."
- else
- git branch --force "$branch" "$hash_after_rebase"
- echo "Make PR, record last upstream commit in PR message"
- # detect landing of pr, tag the last commit with
- # git tag "upstream-commit-$(...)" -m "$(...)"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement