-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild
executable file
·46 lines (33 loc) · 1.04 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -e
case "$1" in
-h|-help|--help)
cat <<EOF
Build a monorepo from multiple existing repos.
Usage: build REPOSFILE [DEFAULT_BRANCH]
REPOSFILE should be named foo.repos where foo is the name of the directory to
build the monoropo in and should contain either github URLs or paths to bare
repo's .git directories, one per line.
BRANCH is the branch name that will be created as the main branch in the mono
repo. Defaults to 'main'. All other branches from incorporated repos will be
mapped to new branchs in the monorepo.
EOF
exit 0
;;
esac
source "$(dirname $0)/monorepo.sh"
here=$(pwd)
input=$(realpath "$1")
branch=${2:-main}
ensure_repo_dir "$(basename "$1" .repos)"
while read -r repo; do
# Accept either github URLs or a path to a bare repo .git directory.
if [ "${repo:0:15}" != "[email protected]:" ]; then
repo=$(cd "$here"; realpath "$repo")
fi
name=${repo##*/}
name=${name%.git}
echo "Incorporating $name ..."
incorporate "$name" "$repo"
done < "$input"
pushdown "$branch"