mirror of
git://f0xx.org/ac/ac-scripts
synced 2026-07-29 02:19:10 +03:00
git: deps manifest and sync-repo-deps-submodules.sh
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
21
git/deps.manifest.tsv
Normal file
21
git/deps.manifest.tsv
Normal file
@@ -0,0 +1,21 @@
|
||||
# ac/* internal cross-repo submodule manifest (path: deps/<repo>)
|
||||
# Format: parent_repo<TAB>dep_repo[:branch] (comma-separated deps)
|
||||
# Used by sync-repo-deps-submodules.sh — external deps stay in third-party/ per repo.
|
||||
ac-platform-php ac-platform-db
|
||||
ac-ms-build ac-platform-php,ac-platform-db
|
||||
ac-ms-devices ac-platform-php,ac-platform-db
|
||||
ac-ms-graphs ac-platform-php,ac-platform-db
|
||||
ac-ms-identity ac-platform-php,ac-platform-db
|
||||
ac-ms-issues ac-platform-php,ac-platform-db
|
||||
ac-ms-rbac ac-platform-php,ac-platform-db
|
||||
ac-ms-remote-access ac-platform-php,ac-platform-db
|
||||
ac-ms-tickets ac-platform-php,ac-platform-db
|
||||
ac-ms-url-shortener ac-platform-db
|
||||
ac-be-access ac-platform-php,ac-platform-web,ac-ms-rbac
|
||||
ac-be-auth ac-platform-php,ac-platform-web,ac-ms-identity
|
||||
ac-be-builder ac-platform-php,ac-platform-web,ac-ms-build
|
||||
ac-be-graphs ac-platform-php,ac-platform-web,ac-ms-graphs
|
||||
ac-be-issues ac-platform-php,ac-platform-web,ac-ms-issues,ac-ms-tickets
|
||||
ac-be-remote-access ac-platform-php,ac-platform-web,ac-ms-remote-access
|
||||
ac-be-tickets ac-platform-php,ac-platform-web,ac-ms-tickets
|
||||
ac-be-hub ac-platform-web
|
||||
|
102
git/sync-repo-deps-submodules.sh
Executable file
102
git/sync-repo-deps-submodules.sh
Executable file
@@ -0,0 +1,102 @@
|
||||
#!/bin/sh
|
||||
# Register internal ac/* repos as git submodules under deps/<name>.
|
||||
# External upstreams (libvpx, opus, …) belong in third-party/ — not this script.
|
||||
#
|
||||
# Usage:
|
||||
# ./sync-repo-deps-submodules.sh ac-be-remote-access
|
||||
# ./sync-repo-deps-submodules.sh --all # every row in deps.manifest.tsv
|
||||
# AC_GIT_BASE=git://127.0.0.1/ac ./sync-repo-deps-submodules.sh --all
|
||||
set -eu
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
MANIFEST="${DEPS_MANIFEST:-$SCRIPT_DIR/deps.manifest.tsv}"
|
||||
AC_GIT_BASE="${AC_GIT_BASE:-git://f0xx.org/ac}"
|
||||
DEFAULT_BRANCH="${AC_GIT_BRANCH:-next}"
|
||||
GIT_AUTHOR_NAME="${GIT_AUTHOR_NAME:-Anton Afanasyeu}"
|
||||
GIT_AUTHOR_EMAIL="${GIT_AUTHOR_EMAIL:-a.afanasieff@gmail.com}"
|
||||
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
|
||||
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
|
||||
|
||||
log() { printf '[sync-deps] %s\n' "$*"; }
|
||||
warn() { printf '[sync-deps] WARN: %s\n' "$*" >&2; }
|
||||
|
||||
deps_for_repo() {
|
||||
_repo="$1"
|
||||
awk -F'\t' -v r="$_repo" '$1 == r && $2 != "" { print $2; exit }' "$MANIFEST"
|
||||
}
|
||||
|
||||
add_dep() {
|
||||
_parent="$1"
|
||||
_dep="$2"
|
||||
_branch="${3:-$DEFAULT_BRANCH}"
|
||||
_path="deps/$_dep"
|
||||
_url="${AC_GIT_BASE}/${_dep}"
|
||||
[ -e "$_parent/.git" ] || { warn "skip $_parent (not a git repo)"; return 1; }
|
||||
cd "$_parent"
|
||||
if [ -d "$_path/.git" ] || [ -f "$_path/.git" ]; then
|
||||
log "$_parent: $_path already present"
|
||||
return 0
|
||||
fi
|
||||
mkdir -p deps
|
||||
log "$_parent: submodule add $_dep → $_path"
|
||||
git submodule add -b "$_branch" "$_url" "$_path"
|
||||
return 0
|
||||
}
|
||||
|
||||
sync_one() {
|
||||
_repo="$1"
|
||||
_root="${REPO_ROOT:-}"
|
||||
if [ -n "$_root" ]; then
|
||||
_parent="$_root/$_repo"
|
||||
else
|
||||
_parent="$_repo"
|
||||
fi
|
||||
_deps="$(deps_for_repo "$_repo")"
|
||||
[ -n "$_deps" ] || { warn "no manifest entry for $_repo"; return 0; }
|
||||
_old_ifs="$IFS"
|
||||
IFS=','
|
||||
for _entry in $_deps; do
|
||||
IFS="$_old_ifs"
|
||||
_dep="$_entry"
|
||||
_branch="$DEFAULT_BRANCH"
|
||||
case "$_entry" in
|
||||
*:*)
|
||||
_dep="${_entry%%:*}"
|
||||
_branch="${_entry#*:}"
|
||||
;;
|
||||
esac
|
||||
add_dep "$_parent" "$_dep" "$_branch" || true
|
||||
done
|
||||
IFS="$_old_ifs"
|
||||
cd "$_parent"
|
||||
if git diff --cached --quiet; then
|
||||
log "$_repo: no submodule changes"
|
||||
return 0
|
||||
fi
|
||||
git commit -m "deps: register internal ac/* submodules under deps/"
|
||||
log "$_repo: committed deps submodules"
|
||||
}
|
||||
|
||||
if [ ! -f "$MANIFEST" ]; then
|
||||
echo "missing manifest: $MANIFEST" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "${1:-}" in
|
||||
--all)
|
||||
awk -F'\t' '$1 !~ /^#/ && $1 != "" { print $1 }' "$MANIFEST" | while read -r _r; do
|
||||
sync_one "$_r"
|
||||
done
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 <repo>|--all"
|
||||
exit 0
|
||||
;;
|
||||
"")
|
||||
echo "repo name or --all required" >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
sync_one "$1"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user