Commit 559acff3 authored by Michal Sojka's avatar Michal Sojka

Add script for initial merge of new repos

See the comments in the script for more details.
parent 425e096a
#!/bin/bash
# When a new brutegit repo is created, it is necessary to merge its
# content (README.md) with the brutegit-ae-sync generated content to
# prevent the following errors:
#
# GitLab: You are not allowed to force push code to a protected
# branch on this project.
#
# This script does exactly that. Run it in your local clone of the
# course repo.
get_ae_branches() {
local commit=${1:?}
git config --blob "${commit}:.brutegit-ae-sync" --get-regexp --name-only '^.*\.path$' \
| awk -F . '{print $1}' \
| uniq
}
set -e
# Update remote branches
git fetch origin
for branch in $(get_ae_branches HEAD); do
url=$(git config --blob "${commit}:.brutegit-ae-sync" --get "$branch".url)
git fetch "$url"
merge_commit=$(git commit-tree refs/remotes/origin/"$branch"^{tree} \
-p refs/remotes/origin/"$branch" -p FETCH_HEAD <<<"Initial merge")
git push origin $merge_commit:$branch
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment