Rename default branch to ‘main’
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
285a946a1f
commit
53e59c8c09
13 changed files with 39 additions and 39 deletions
|
@ -2,9 +2,9 @@
|
|||
set -e
|
||||
|
||||
# usage: clean-branches
|
||||
# Deletes any local branches which are ancestors of origin/master,
|
||||
# Deletes any local branches which are ancestors of origin/main,
|
||||
# and also any branches in origin which are ancestors of
|
||||
# origin/master and are named like $USER-*.
|
||||
# origin/main and are named like $USER-*.
|
||||
|
||||
# usage: clean-branches --reviews
|
||||
# Deletes all the above mentioned branches as well as branches
|
||||
|
@ -18,13 +18,13 @@ fi
|
|||
push_args=()
|
||||
|
||||
function is_merged {
|
||||
! git rev-list -n 1 origin/master.."$1" | grep -q .
|
||||
! git rev-list -n 1 origin/main.."$1" | grep -q .
|
||||
}
|
||||
|
||||
function clean_ref {
|
||||
ref="$1"
|
||||
case "$ref" in
|
||||
*/master | */HEAD)
|
||||
*/main | */HEAD)
|
||||
return
|
||||
;;
|
||||
|
||||
|
@ -56,8 +56,8 @@ function clean_ref {
|
|||
esac
|
||||
}
|
||||
|
||||
if [ "$(git symbolic-ref HEAD)" != 'refs/heads/master' ]; then
|
||||
echo "Check out master before you run this script." >&2
|
||||
if [ "$(git symbolic-ref HEAD)" != 'refs/heads/main' ]; then
|
||||
echo "Check out main before you run this script." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ branch_ref=$(git rev-list --max-count=1 "$branch")
|
|||
[ $? -ne 0 ] && error_out "Unknown branch: $branch"
|
||||
|
||||
if [ "$old_ref" == "$branch_ref" ]; then
|
||||
new_ref=master
|
||||
new_ref=main
|
||||
else
|
||||
ref_name=$(git describe --all --exact "$old_ref")
|
||||
if [ $? -eq 0 ]; then
|
||||
|
@ -31,12 +31,12 @@ fi
|
|||
|
||||
git fetch -p
|
||||
|
||||
git rebase origin/master "$branch"
|
||||
[ $? -ne 0 ] && error_out "Rebase onto origin/master failed"
|
||||
git rebase origin/main "$branch"
|
||||
[ $? -ne 0 ] && error_out "Rebase onto origin/main failed"
|
||||
|
||||
git push . HEAD:master
|
||||
git push origin master
|
||||
[ $? -ne 0 ] && error_out "Push of master to origin/master failed"
|
||||
git push . HEAD:main
|
||||
git push origin main
|
||||
[ $? -ne 0 ] && error_out "Push of main to origin/main failed"
|
||||
|
||||
git checkout "$new_ref"
|
||||
git branch -D "$branch"
|
||||
|
|
|
@ -12,6 +12,6 @@ fi
|
|||
request_id="$1"
|
||||
remote=${2:-"upstream"}
|
||||
git fetch "$remote" "pull/$request_id/head"
|
||||
git checkout -B "review-${request_id}" $remote/master
|
||||
git checkout -B "review-${request_id}" $remote/main
|
||||
git reset --hard FETCH_HEAD
|
||||
git pull --rebase
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# Edited at Line 14 Col 97 (zulip -> python-zulip-api)
|
||||
# Please don't edit here; instead update the zulip/zulip copy and then resync this file.
|
||||
|
||||
# Lint all commit messages that are newer than upstream/master if running
|
||||
# Lint all commit messages that are newer than upstream/main if running
|
||||
# locally or the commits in the push or PR Gh-Actions.
|
||||
|
||||
# The rules can be found in /.gitlint
|
||||
|
@ -16,9 +16,9 @@ $(git remote -v)
|
|||
" =~ '
|
||||
'([^[:space:]]*)[[:space:]]*(https://github\.com/|ssh://git@github\.com/|git@github\.com:)"$repository"(\.git|/)?\ \(fetch\)'
|
||||
' ]]; then
|
||||
range="${BASH_REMATCH[1]}/master..HEAD"
|
||||
range="${BASH_REMATCH[1]}/main..HEAD"
|
||||
else
|
||||
range="upstream/master..HEAD"
|
||||
range="upstream/main..HEAD"
|
||||
fi
|
||||
|
||||
commits=$(git log "$range" | wc -l)
|
||||
|
|
16
tools/review
16
tools/review
|
@ -32,21 +32,21 @@ def check_git_pristine() -> None:
|
|||
exit("Git is not pristine:\n" + output)
|
||||
|
||||
|
||||
def ensure_on_clean_master() -> None:
|
||||
def ensure_on_clean_main() -> None:
|
||||
branch = get_git_branch()
|
||||
if branch != "master":
|
||||
if branch != "main":
|
||||
exit(f"You are still on a feature branch: {branch}")
|
||||
check_git_pristine()
|
||||
run("git fetch upstream master")
|
||||
run("git rebase upstream/master")
|
||||
run("git fetch upstream main")
|
||||
run("git rebase upstream/main")
|
||||
|
||||
|
||||
def create_pull_branch(pull_id: int) -> None:
|
||||
run("git fetch upstream pull/%d/head" % (pull_id,))
|
||||
run(f"git checkout -B review-{pull_id} FETCH_HEAD")
|
||||
run("git rebase upstream/master")
|
||||
run("git log upstream/master.. --oneline")
|
||||
run("git diff upstream/master.. --name-status")
|
||||
run("git rebase upstream/main")
|
||||
run("git log upstream/main.. --oneline")
|
||||
run("git diff upstream/main.. --name-status")
|
||||
|
||||
print()
|
||||
print("PR: %d" % (pull_id,))
|
||||
|
@ -59,7 +59,7 @@ def review_pr() -> None:
|
|||
except Exception:
|
||||
exit("please provide an integer pull request id")
|
||||
|
||||
ensure_on_clean_master()
|
||||
ensure_on_clean_main()
|
||||
create_pull_branch(pull_id)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue