-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add jane/pull-flambda-patches script
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 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,47 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
repo="$(git rev-parse --show-toplevel)" | ||
cd "$repo" | ||
|
||
if ! git diff --quiet; then | ||
echo "Working directory must be clean before using this script," | ||
echo "but currently has the following changes:" | ||
git diff --stat | ||
exit 1 | ||
fi | ||
|
||
configure_remote () { | ||
name="$1" | ||
url="$2" | ||
set +e | ||
curr="$(git remote get-url "$name" 2>/dev/null)" | ||
err=$? | ||
set -e | ||
if [ $err = 2 ]; then | ||
git remote add "$name" "$url" | ||
elif [ "$curr" != "$url" ]; then | ||
{ | ||
echo "Error: remote $name should point to $url, not $curr" | ||
echo "Try 'git remote rm $name'." | ||
} 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
configure_remote origin 'git@github.com:janestreet/ocaml-jst' | ||
configure_remote flambda-backend 'git@github.com:ocaml-flambda/flambda-backend' | ||
configure_remote ocaml 'git@github.com:ocaml/ocaml' | ||
|
||
git fetch -q origin | ||
git fetch -q flambda-backend | ||
|
||
git checkout -q flambda-backend/main | ||
rev=$(git subtree split -P ocaml --annotate='flambda-backend: ' flambda-backend/main) | ||
git push -q origin $rev:refs/heads/flambda-patches |& sed '/^remote: /d' | ||
git checkout -q - | ||
|
||
count=$(git rev-list HEAD..origin/flambda-patches | wc -l) | ||
echo "$count new patches:" | ||
git --no-pager log --oneline HEAD..origin/flambda-patches | ||
git merge --no-ff -m 'Merge flambda-backend changes' origin/flambda-patches |