Skip to content

CB-6291 Build (local) script do not clone all required repos for successful build #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions scripts/git_utils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env sh

repo_path() {
local root_dir="$1"
local repo="$2"
echo "$root_dir/$repo"
}

ensure_repo_cloned() {
local root_dir="$1"
local repo="$2"
echo "ensuring that repo $repo is cloned"
if [ -d "$(repo_path "$root_dir" "$repo")" ]; then
echo "$(repo_path "$root_dir" "$repo") is already cloned"
else
git clone "https://github.com/dbeaver/$repo.git" "$(repo_path "$root_dir" "$repo")"
fi
}

clone_dependencies() {
local root_dir="$1"
local repo="$2"
echo "cloning dependencies for $repo"
project_dependencies_file=$(repo_path "$root_dir" "$repo")/project.deps
echo "reading dependencies file $project_dependencies_file"
while IFS= read -r dep_repo || [[ -n "$dep_repo" ]]; do
ensure_repo_cloned "$root_dir" "$dep_repo"
done < "$project_dependencies_file"
}

# Example of usage:
# script_dir="$(realpath "$(dirname "$0")")"
# repositories_root_dir="$(realpath "$script_dir/../..")" <======== ENTER CORRECT PATH HERE DEPENDING ON YOUR SCRIPT LOCATION
# [ ! -d "$repositories_root_dir/dbeaver-common" ] && git clone --depth 1 https://github.com/dbeaver/dbeaver-common.git "$repositories_root_dir/dbeaver-common"
# source "$repositories_root_dir/dbeaver-common/scripts/git_utils.sh

prepare_repo_and_dependencies() {
if [ $# -ne 2 ]; then
echo "Usage: prepare_repo_and_dependencies <repositories_root_dir> <repo_name>"
return 1
fi

local repositories_root_dir="$1"
local repo_name="$2"

echo "preparing repo $repo_name in $repositories_root_dir"
ensure_repo_cloned "$repositories_root_dir" "$repo_name"
clone_dependencies "$repositories_root_dir" "$repo_name"
}

export prepare_repo_and_dependencies
Loading