xen-orchestra/scripts/import-packages

35 lines
933 B
Plaintext
Raw Normal View History

#!/bin/sh
if [ $# -eq 0 ]
then
echo "$0 <repository url>..."
exit
fi
# Import repositories into this mono-repo.
#
# For each repository:
#
# 1. rewrite history, moving all files into packages/<repository>
# 2. rename all tags: <tag> → <repository>-<tag>
# 3. merge with master
for url
do
pkg=$(basename "$url" .git)
[ -d "packages/$pkg" ] || { {
[ -f ".git/refs/remotes/$pkg/master" ] || \
git remote add "$pkg" "$url"
} && {
git fetch --no-tags "$pkg" master refs/tags/*:refs/tags/"$pkg"-* && \
git filter-branch -f --index-filter '
git ls-files -s | \
sed "s%\t\"*%&packages/'"$pkg"'/%" | \
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info && \
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
' --tag-name-filter 'cat' "$pkg/master" && \
git merge --allow-unrelated-histories "$pkg/master"
git remote rm "$pkg"
} }
done