Merge pull request 'Update Contributing guide to external developers' (#1484) from Qubasa/clan-core:main into main #1504
25
pkgs/merge-after-ci/merge-after-ci.py
Normal file → Executable file
25
pkgs/merge-after-ci/merge-after-ci.py
Normal file → Executable file
@ -1,4 +1,5 @@
|
||||
import argparse
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
@ -11,14 +12,16 @@ args = parser.parse_args()
|
||||
if not args.reviewers and not args.no_review:
|
||||
parser.error("either --reviewers or --no-review must be given")
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
"tea-create-pr",
|
||||
"origin",
|
||||
"main",
|
||||
"--assignees",
|
||||
",".join(["clan-bot", *args.reviewers]),
|
||||
*(["--labels", "needs-review"] if not args.no_review else []),
|
||||
*args.args,
|
||||
]
|
||||
)
|
||||
cmd = [
|
||||
"tea-create-pr",
|
||||
"origin",
|
||||
"main",
|
||||
"--assignees",
|
||||
",".join(["clan-bot", *args.reviewers]),
|
||||
*(["--labels", "needs-review"] if not args.no_review else []),
|
||||
*args.args,
|
||||
]
|
||||
|
||||
print("Running:", shlex.join(cmd))
|
||||
|
||||
subprocess.run(cmd)
|
||||
|
27
pkgs/tea-create-pr/script.sh
Normal file → Executable file
27
pkgs/tea-create-pr/script.sh
Normal file → Executable file
@ -8,9 +8,29 @@ TMPDIR="$(mktemp -d)"
|
||||
currentBranch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
user="$(tea login list -o simple | cut -d" " -f4 | head -n1)"
|
||||
tempRemoteBranch="$user-$currentBranch"
|
||||
root_dir=$(git rev-parse --show-toplevel)
|
||||
|
||||
nix fmt -- --fail-on-change
|
||||
# Function to check if a remote exists
|
||||
check_remote() {
|
||||
if git remote get-url "$1" > /dev/null 2>&1; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if the remote 'upstream' is defined
|
||||
if ! check_remote upstream; then
|
||||
echo "Error: Upstream remote is not defined."
|
||||
echo "Please fork the repository and add the upstream remote."
|
||||
echo "$ git remote add upstream <upstream-url>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
upstream_url=$(git remote get-url upstream)
|
||||
repo=$(echo "$upstream_url" | sed -E 's#.*:([^/]+/[^.]+)\.git#\1#')
|
||||
|
||||
treefmt -C "$root_dir"
|
||||
git log --reverse --pretty="format:%s%n%n%b%n%n" "$remoteName/$targetBranch..HEAD" > "$TMPDIR"/commit-msg
|
||||
|
||||
$EDITOR "$TMPDIR"/commit-msg
|
||||
@ -23,11 +43,12 @@ 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 \
|
||||
--repo "$repo" \
|
||||
--head "$user:$currentBranch" \
|
||||
--title "$firstLine" \
|
||||
--description "$rest" \
|
||||
--head "$tempRemoteBranch" \
|
||||
--base "$targetBranch" \
|
||||
"$@"
|
Loading…
Reference in New Issue
Block a user