Files
Luis 9238225556
Some checks failed
checks-impure / test (pull_request) Failing after 3m11s
checks / test (pull_request) Failing after 24m9s
Fixing merge-after-ci
2023-10-23 02:12:42 +02:00

34 lines
801 B
Bash

#!/usr/bin/env bash
set -euo pipefail
remoteName="${1:-origin}"
targetBranch="${2:-main}"
shift && shift
TMPDIR="$(mktemp -d)"
currentBranch="$(git rev-parse --abbrev-ref HEAD)"
user="$(git config --get user.name)"
tempRemoteBranch="$user-$currentBranch"
nix fmt -- --fail-on-change
git log --reverse --pretty="format:%s%n%n%b%n%n" "$remoteName/$targetBranch..HEAD" > "$TMPDIR"/commit-msg
$EDITOR "$TMPDIR"/commit-msg
COMMIT_MSG=$(cat "$TMPDIR"/commit-msg)
firstLine=$(echo "$COMMIT_MSG" | head -n1)
rest=$(echo "$COMMIT_MSG" | tail -n+2)
if [[ "$firstLine" == "$rest" ]]; then
rest=""
fi
git push --force -u "$remoteName" HEAD:refs/heads/"$tempRemoteBranch"
tea pr create \
--title "$firstLine" \
--description "$rest" \
--head "$tempRemoteBranch" \
--base "$targetBranch" \
"$@"